Adds mongo e2e spec (#207)

* Adds mongo e2e spec

* Adds mongo connection string

* Constantize sql spec

* Use shared login function

* Remove comment

* Remove login lines from cassandra

* Adds frame return tyoe

* test updates

* format

* adds unique name

* remove trivial type annotation
This commit is contained in:
Zachary Foster
2020-09-30 16:42:33 -04:00
committed by GitHub
parent fc722e87be
commit 4fe2098730
9 changed files with 194 additions and 59 deletions

View File

@@ -1,25 +1,17 @@
import "expect-puppeteer";
import crypto from "crypto";
import { generateUniqueName, login } from "../utils/shared";
jest.setTimeout(300000);
const LOADING_STATE_DELAY = 2500;
const RENDER_DELAY = 1000;
describe("Collection Add and Delete SQL spec", () => {
it("creates a collection", async () => {
try {
const dbId = `TestDatabase${crypto.randomBytes(8).toString("hex")}`;
const collectionId = `TestCollection${crypto.randomBytes(8).toString("hex")}`;
const sharedKey = `SharedKey${crypto.randomBytes(8).toString("hex")}`;
const prodUrl = "https://localhost:1234/hostedExplorer.html";
page.goto(prodUrl);
// log in with connection string
const handle = await page.waitForSelector("iframe");
const frame = await handle.contentFrame();
await frame.waitFor("div > p.switchConnectTypeText", { visible: true });
await frame.click("div > p.switchConnectTypeText");
const connStr = process.env.PORTAL_RUNNER_CONNECTION_STRING;
await frame.type("input[class='inputToken']", connStr);
await frame.click("input[value='Connect']");
const dbId = generateUniqueName("TestDatabase");
const collectionId = generateUniqueName("TestCollection");
const sharedKey = generateUniqueName("SharedKey");
const frame = await login(process.env.PORTAL_RUNNER_CONNECTION_STRING);
// create new collection
await frame.waitFor('button[data-test="New Container"]', { visible: true });
@@ -55,20 +47,20 @@ describe("Collection Add and Delete SQL spec", () => {
await frame.waitFor(`span[title="${dbId}"]`);
await frame.waitForSelector('div[class="splashScreen"] > div[class="title"]', { visible: true });
await frame.waitFor(`div[data-test="${dbId}"]`), { visible: true };
await frame.click(`div[data-test="${dbId}"]`);
await frame.waitFor(3000);
await frame.waitFor(`span[title="${collectionId}"]`, { visible: true });
await frame.waitFor(RENDER_DELAY);
await frame.waitFor(`div[data-test="${collectionId}"]`, { visible: true });
// delete container
// click context menu for container
await frame.waitFor(`div[data-test="${collectionId}"] > div > button`, { visible: true });
await frame.waitFor(`span[title="${collectionId}"]`, { visible: true });
await frame.click(`div[data-test="${collectionId}"] > div > button`);
await frame.waitFor(2000);
// click delete container
await frame.waitFor('span[class="treeComponentMenuItemLabel deleteCollectionMenuItemLabel"]', { visible: true });
await frame.waitFor(RENDER_DELAY);
await frame.waitFor('span[class="treeComponentMenuItemLabel deleteCollectionMenuItemLabel"]');
await frame.click('span[class="treeComponentMenuItemLabel deleteCollectionMenuItemLabel"]');
// confirm delete container
@@ -78,7 +70,7 @@ describe("Collection Add and Delete SQL spec", () => {
// click delete
await frame.waitFor('input[data-test="deleteCollection"]', { visible: true });
await frame.click('input[data-test="deleteCollection"]');
await frame.waitFor(5000);
await frame.waitFor(LOADING_STATE_DELAY);
await frame.waitForSelector('div[class="splashScreen"] > div[class="title"]', { visible: true });
await expect(page).not.toMatchElement(`div[data-test="${collectionId}"]`);
@@ -94,6 +86,8 @@ describe("Collection Add and Delete SQL spec", () => {
await frame.click('span[class="treeComponentMenuItemLabel deleteDatabaseMenuItemLabel"]');
// confirm delete database
await frame.waitForSelector('input[data-test="confirmDatabaseId"]', { visible: true });
await frame.waitFor(RENDER_DELAY);
await frame.type('input[data-test="confirmDatabaseId"]', dbId.trim());
// click delete