End to End Test Improvements (#474)

* End to End Test Improvements

* indenting

* Log completed

* Fix up some test

* Add delay

Co-authored-by: Steve Faulkner <stfaul@microsoft.com>
This commit is contained in:
Steve Faulkner
2021-03-04 18:12:31 -06:00
committed by GitHub
parent 87e016f03c
commit 498c39c877
9 changed files with 142 additions and 60 deletions

View File

@@ -1,6 +1,6 @@
import "expect-puppeteer";
import { Frame } from "puppeteer";
import { generateUniqueName, login } from "../utils/shared";
import { generateDatabaseName, generateUniqueName, login } from "../utils/shared";
jest.setTimeout(300000);
const LOADING_STATE_DELAY = 2500;
@@ -11,7 +11,7 @@ const RENDER_DELAY = 1000;
describe("Collection Add and Delete Mongo spec", () => {
it("creates a collection", async () => {
try {
const dbId = generateUniqueName("db");
const dbId = generateDatabaseName();
const collectionId = generateUniqueName("col");
const sharedKey = `${generateUniqueName()}`;
const frame = await login(process.env.MONGO_CONNECTION_STRING);

View File

@@ -5,7 +5,6 @@ import { generateUniqueName } from "../utils/shared";
import { ApiKind } from "../../src/Contracts/DataModels";
const LOADING_STATE_DELAY = 3000;
const CREATE_DELAY = 5000;
jest.setTimeout(300000);
describe("MongoDB Index policy tests", () => {
@@ -24,15 +23,16 @@ describe("MongoDB Index policy tests", () => {
let databases = await frame.$$(`div[class="databaseHeader main1 nodeItem "] > div[class="treeNodeHeader "]`);
if (databases.length === 0) {
await createDatabase(frame);
await frame.waitFor(25000);
databases = await frame.$$(`div[class="databaseHeader main1 nodeItem "] > div[class="treeNodeHeader "]`);
}
const selectedDbId = await frame.evaluate((element) => {
return element.attributes["data-test"].textContent;
}, databases[0]);
const selectedDbId = (await frame.evaluate((element) => element.innerText, databases[0]))
.replace(/[\u{0080}-\u{FFFF}]/gu, "")
.trim();
// click on database
await frame.waitFor(`div[data-test="${selectedDbId}"]`);
await frame.waitForSelector(`div[data-test="${selectedDbId}"]`);
await frame.waitFor(LOADING_STATE_DELAY);
await frame.click(`div[data-test="${selectedDbId}"]`);
await frame.waitFor(LOADING_STATE_DELAY);
@@ -41,9 +41,9 @@ describe("MongoDB Index policy tests", () => {
const containers = await frame.$$(
`div[class="nodeChildren"] > div[class="collectionHeader main2 nodeItem "]> div[class="treeNodeHeader "]`
);
const selectedContainer = await frame.evaluate((element) => {
return element.attributes["data-test"].textContent;
}, containers[0]);
const selectedContainer = (await frame.evaluate((element) => element.innerText, containers[0]))
.replace(/[\u{0080}-\u{FFFF}]/gu, "")
.trim();
await frame.waitFor(`div[data-test="${selectedContainer}"]`), { visible: true };
await frame.waitFor(LOADING_STATE_DELAY);
await frame.click(`div[data-test="${selectedContainer}"]`);
@@ -94,7 +94,7 @@ describe("MongoDB Index policy tests", () => {
singleFieldIndexInserted = true;
}
}
await frame.waitFor(LOADING_STATE_DELAY);
await frame.waitFor(20000);
expect(wildCardIndexInserted).toBe(true);
expect(singleFieldIndexInserted).toBe(true);
@@ -107,7 +107,7 @@ describe("MongoDB Index policy tests", () => {
await onClickSaveButton(frame);
//check for cleaning
await frame.waitFor(CREATE_DELAY);
await frame.waitFor(20000);
await frame.waitFor("div[data-automationid='DetailsRowCell'] > span"), { visible: true };
const isDeletionComplete = await frame.$$("div[data-automationid='DetailsRowCell'] > span");
expect(isDeletionComplete).toHaveLength(2);