2021-02-18 13:40:58 +00:00
|
|
|
import "expect-puppeteer";
|
2021-03-15 03:53:16 +00:00
|
|
|
import { createDatabase, generateUniqueName, onClickSaveButton } from "../utils/shared";
|
2021-02-18 13:40:58 +00:00
|
|
|
|
2021-03-08 20:41:12 +00:00
|
|
|
const LOADING_STATE_DELAY = 5000;
|
2021-02-18 13:40:58 +00:00
|
|
|
jest.setTimeout(300000);
|
|
|
|
|
|
|
|
describe("MongoDB Index policy tests", () => {
|
|
|
|
it("Open, Create and Save Index", async () => {
|
|
|
|
try {
|
|
|
|
const singleFieldId = generateUniqueName("key");
|
|
|
|
const wildCardId = generateUniqueName("key") + "$**";
|
2021-03-15 03:53:16 +00:00
|
|
|
await page.goto("https://localhost:1234/testExplorer.html?accountName=portal-mongo-runner");
|
|
|
|
const handle = await page.waitForSelector("iframe");
|
|
|
|
const frame = await handle.contentFrame();
|
2021-02-18 13:40:58 +00:00
|
|
|
const dropDown = "Index Type ";
|
|
|
|
let index = 0;
|
|
|
|
|
|
|
|
//open dataBaseMenu
|
|
|
|
await frame.waitForSelector('div[class="splashScreen"] > div[class="title"]', { visible: true });
|
|
|
|
await frame.waitFor(LOADING_STATE_DELAY);
|
|
|
|
await frame.waitForSelector('div[class="splashScreen"] > div[class="title"]', { visible: true });
|
2021-03-15 03:53:16 +00:00
|
|
|
const { databaseId, collectionId } = await createDatabase(frame);
|
2021-03-05 04:49:52 +00:00
|
|
|
await frame.waitFor(25000);
|
2021-02-18 13:40:58 +00:00
|
|
|
// click on database
|
2021-03-15 03:53:16 +00:00
|
|
|
await frame.waitForSelector(`div[data-test="${databaseId}"]`);
|
2021-02-18 13:40:58 +00:00
|
|
|
await frame.waitFor(LOADING_STATE_DELAY);
|
2021-03-15 03:53:16 +00:00
|
|
|
await frame.click(`div[data-test="${databaseId}"]`);
|
2021-02-18 13:40:58 +00:00
|
|
|
await frame.waitFor(LOADING_STATE_DELAY);
|
|
|
|
|
|
|
|
// click on scale & setting
|
2021-03-15 03:53:16 +00:00
|
|
|
await frame.waitFor(`div[data-test="${collectionId}"]`), { visible: true };
|
2021-02-18 13:40:58 +00:00
|
|
|
await frame.waitFor(LOADING_STATE_DELAY);
|
2021-03-15 03:53:16 +00:00
|
|
|
await frame.click(`div[data-test="${collectionId}"]`);
|
2021-02-18 13:40:58 +00:00
|
|
|
|
|
|
|
await frame.waitFor(`div[data-test="Scale & Settings"]`), { visible: true };
|
2021-03-17 21:02:20 +00:00
|
|
|
await frame.waitFor(10000);
|
2021-02-18 13:40:58 +00:00
|
|
|
await frame.click(`div[data-test="Scale & Settings"]`);
|
|
|
|
|
|
|
|
await frame.waitFor(`button[data-content="Indexing Policy"]`), { visible: true };
|
|
|
|
await frame.waitFor(LOADING_STATE_DELAY);
|
|
|
|
await frame.click(`button[data-content="Indexing Policy"]`);
|
|
|
|
|
|
|
|
// Type to single Field
|
|
|
|
let throughput = await frame.$$(".ms-TextField-field");
|
|
|
|
const selectedDropDownSingleField = dropDown + index;
|
|
|
|
await frame.waitFor(`div[aria-label="${selectedDropDownSingleField}"]`), { visible: true };
|
|
|
|
await throughput[index].type(singleFieldId);
|
|
|
|
await frame.click(`div[aria-label="${selectedDropDownSingleField}"]`);
|
|
|
|
await frame.waitFor(LOADING_STATE_DELAY);
|
|
|
|
await frame.click(`button[title="Single Field"]`);
|
|
|
|
index++;
|
|
|
|
|
|
|
|
// Type to wild card
|
|
|
|
throughput = await frame.$$(".ms-TextField-field");
|
|
|
|
await throughput[index].type(wildCardId);
|
|
|
|
const selectedDropDownWildCard = dropDown + index;
|
|
|
|
await frame.waitFor(`div[aria-label="${selectedDropDownWildCard}"]`), { visible: true };
|
|
|
|
await frame.click(`div[aria-label="${selectedDropDownWildCard}"]`);
|
|
|
|
await frame.waitFor(LOADING_STATE_DELAY);
|
|
|
|
await frame.click(`button[title="Wildcard"]`);
|
|
|
|
index++;
|
|
|
|
|
|
|
|
// click save Button
|
|
|
|
await onClickSaveButton(frame);
|
|
|
|
|
|
|
|
// check the array
|
|
|
|
let singleFieldIndexInserted = false,
|
|
|
|
wildCardIndexInserted = false;
|
|
|
|
await frame.waitFor("div[data-automationid='DetailsRowCell'] > span"), { visible: true };
|
2021-03-08 20:41:12 +00:00
|
|
|
await frame.waitFor(20000);
|
2021-02-18 13:40:58 +00:00
|
|
|
|
|
|
|
const elements = await frame.$$("div[data-automationid='DetailsRowCell'] > span");
|
|
|
|
for (let i = 0; i < elements.length; i++) {
|
|
|
|
const element = elements[i];
|
|
|
|
const text = await frame.evaluate((element) => element.textContent, element);
|
|
|
|
if (text.includes(wildCardId)) {
|
|
|
|
wildCardIndexInserted = true;
|
|
|
|
} else if (text.includes(singleFieldId)) {
|
|
|
|
singleFieldIndexInserted = true;
|
|
|
|
}
|
|
|
|
}
|
2021-03-05 00:12:31 +00:00
|
|
|
await frame.waitFor(20000);
|
2021-02-18 13:40:58 +00:00
|
|
|
expect(wildCardIndexInserted).toBe(true);
|
|
|
|
expect(singleFieldIndexInserted).toBe(true);
|
|
|
|
|
|
|
|
//delete all index policy
|
|
|
|
await frame.waitFor("button[aria-label='Delete index Button']"), { visible: true };
|
|
|
|
const deleteButton = await frame.$$("button[aria-label='Delete index Button']");
|
|
|
|
for (let i = 0; i < deleteButton.length; i++) {
|
|
|
|
await frame.click(`button[aria-label="Delete index Button"]`);
|
|
|
|
}
|
|
|
|
await onClickSaveButton(frame);
|
|
|
|
|
|
|
|
//check for cleaning
|
2021-03-05 00:12:31 +00:00
|
|
|
await frame.waitFor(20000);
|
2021-02-18 13:40:58 +00:00
|
|
|
await frame.waitFor("div[data-automationid='DetailsRowCell'] > span"), { visible: true };
|
|
|
|
const isDeletionComplete = await frame.$$("div[data-automationid='DetailsRowCell'] > span");
|
|
|
|
expect(isDeletionComplete).toHaveLength(2);
|
|
|
|
} catch (error) {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
const testName = (expect as any).getState().currentTestName;
|
2021-03-05 04:49:52 +00:00
|
|
|
await page.screenshot({ path: `failed-${testName}.jpg` });
|
2021-02-18 13:40:58 +00:00
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|