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,49 +1,39 @@
import "expect-puppeteer";
import crypto from 'crypto'
import { generateUniqueName, login } from "../utils/shared";
jest.setTimeout(300000);
const RENDER_DELAY = 400
const LOADING_STATE_DELAY = 1800
const RENDER_DELAY = 400;
const LOADING_STATE_DELAY = 2500;
describe('Collection Add and Delete Cassandra spec', () => {
it('creates a collection', async () => {
describe("Collection Add and Delete Cassandra spec", () => {
it("creates a collection", async () => {
try {
const keyspaceId = `keyspaceid${crypto.randomBytes(8).toString("hex")}`;
const tableId = `tableid${crypto.randomBytes(3).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.CASSANDRA_CONNECTION_STRING;
await frame.type("input[class='inputToken']", connStr);
await frame.click("input[value='Connect']");
const keyspaceId = generateUniqueName("keyspaceid");
const tableId = generateUniqueName("tableid");
const frame = await login(process.env.CASSANDRA_CONNECTION_STRING);
// create new table
await frame.waitFor('button[data-test="New Table"]', { visible: true });
await frame.waitForSelector('div[class="splashScreen"] > div[class="title"]', { visible: true });
await frame.click('button[data-test="New Table"]');
await frame.click('button[data-test="New Table"]');
// type keyspace id
await frame.waitFor('input[id="keyspace-id"]', { visible: true });
await frame.type('input[id="keyspace-id"]', keyspaceId);
await frame.type('input[id="keyspace-id"]', keyspaceId);
// type table id
await frame.waitFor('input[class="textfontclr"]');
await frame.type('input[class="textfontclr"]', tableId);
await frame.type('input[class="textfontclr"]', tableId);
// click submit
await frame.waitFor('#cassandraaddcollectionpane > div > form > div.paneFooter > div > input');
await frame.click('#cassandraaddcollectionpane > div > form > div.paneFooter > div > input');
await frame.waitFor("#cassandraaddcollectionpane > div > form > div.paneFooter > div > input");
await frame.click("#cassandraaddcollectionpane > div > form > div.paneFooter > div > input");
// open database menu
await frame.waitForSelector('div[class="splashScreen"] > div[class="title"]', { visible: true });
await frame.waitFor(`div[data-test="${keyspaceId}"]`, { visible: true });
await frame.waitFor(LOADING_STATE_DELAY)
await frame.waitFor(LOADING_STATE_DELAY);
await frame.waitFor(`div[data-test="${keyspaceId}"]`, { visible: true });
await frame.click(`div[data-test="${keyspaceId}"]`);
await frame.waitFor(`span[title="${tableId}"]`, { visible: true });
@@ -55,16 +45,17 @@ describe('Collection Add and Delete Cassandra spec', () => {
await frame.click(`div[data-test="${tableId}"] > div > button`);
// click delete container
await frame.waitForSelector('body > div.ms-Layer.ms-Layer--fixed');
await frame.waitFor(RENDER_DELAY)
const elements = await frame.$$('span[class="treeComponentMenuItemLabel deleteCollectionMenuItemLabel"]')
await elements[0].click()
await frame.waitForSelector("body > div.ms-Layer.ms-Layer--fixed");
await frame.waitFor(RENDER_DELAY);
const elements = await frame.$$('span[class="treeComponentMenuItemLabel deleteCollectionMenuItemLabel"]');
await elements[0].click();
// confirm delete container
await frame.type('input[data-test="confirmCollectionId"]', tableId.trim());
// click delete
await frame.click('input[data-test="deleteCollection"]');
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 });
@@ -78,10 +69,12 @@ describe('Collection Add and Delete Cassandra spec', () => {
// click delete database
await frame.waitFor(RENDER_DELAY);
const dbElements = await frame.$$('span[class="treeComponentMenuItemLabel deleteDatabaseMenuItemLabel"]')
const dbElements = await frame.$$('span[class="treeComponentMenuItemLabel deleteDatabaseMenuItemLabel"]');
await dbElements[0].click();
// confirm delete database
await frame.waitForSelector('input[data-test="confirmDatabaseId"]', { visible: true });
await frame.waitFor(RENDER_DELAY);
await frame.type('input[data-test="confirmDatabaseId"]', keyspaceId.trim());
// click delete
@@ -90,9 +83,9 @@ describe('Collection Add and Delete Cassandra spec', () => {
await expect(page).not.toMatchElement(`div[data-test="${keyspaceId}"]`);
} catch (error) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const testName = (expect as any).getState().currentTestName
await page.screenshot({path: `Test Failed ${testName}.png`});
const testName = (expect as any).getState().currentTestName;
await page.screenshot({ path: `Test Failed ${testName}.png` });
throw error;
}
}
});
});
});