From 30353c26f319c71643347cc48c05194090527e3e Mon Sep 17 00:00:00 2001
From: Zachary Foster
Date: Tue, 20 Oct 2020 11:49:22 -0400
Subject: [PATCH] Adds e2e tables test (#276)
* Adds tables test
* Include .env var
* Adds asElement on again
* Add further loading states
* Format
* Hope to not lose focus
* Adds ID to shared key and modifies value of input directly
* Fix tables test
* Format
* Try uploading screenshots
* indent
* Fixes connection string
* Try wildcard upload path
---
.github/workflows/ci.yml | 5 ++
src/Explorer/Panes/AddCollectionPane.html | 2 +-
test/cassandra/container.spec.ts | 4 +-
test/mongo/container.spec.ts | 4 +-
test/sql/container.spec.ts | 4 +-
test/tables/container.spec.ts | 71 +++++++++++++++++++++++
test/utils/shared.ts | 2 +-
7 files changed, 87 insertions(+), 5 deletions(-)
create mode 100644 test/tables/container.spec.ts
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 78a043e29..53a39150a 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -150,6 +150,11 @@ jobs:
PORTAL_RUNNER_CONNECTION_STRING: ${{ secrets.CONNECTION_STRING_SQL }}
MONGO_CONNECTION_STRING: ${{ secrets.CONNECTION_STRING_MONGO }}
CASSANDRA_CONNECTION_STRING: ${{ secrets.CONNECTION_STRING_CASSANDRA }}
+ TABLES_CONNECTION_STRING: ${{ secrets.CONNECTION_STRING_TABLE }}
+ - uses: actions/upload-artifact@v2
+ with:
+ name: screenshots
+ path: failed-*
nuget:
name: Publish Nuget
if: github.ref == 'refs/heads/master' || contains(github.ref, 'hotfix/') || contains(github.ref, 'release/')
diff --git a/src/Explorer/Panes/AddCollectionPane.html b/src/Explorer/Panes/AddCollectionPane.html
index 94d704046..c41e06440 100644
--- a/src/Explorer/Panes/AddCollectionPane.html
+++ b/src/Explorer/Panes/AddCollectionPane.html
@@ -390,7 +390,7 @@
range of values and is likely to have evenly distributed access patterns.
- {
// click delete
await frame.click('input[data-test="deleteDatabase"]');
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 });
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` });
+ await page.screenshot({ path: `failed-${testName}.jpg` });
throw error;
}
});
diff --git a/test/mongo/container.spec.ts b/test/mongo/container.spec.ts
index 54febbcf1..12d77e2d7 100644
--- a/test/mongo/container.spec.ts
+++ b/test/mongo/container.spec.ts
@@ -101,11 +101,13 @@ describe("Collection Add and Delete Mongo spec", () => {
// click delete
await frame.click('input[data-test="deleteDatabase"]');
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 });
await expect(page).not.toMatchElement(`div[data-test="${dbId}"]`);
} 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` });
+ await page.screenshot({ path: `failed-${testName}.jpg` });
throw error;
}
});
diff --git a/test/sql/container.spec.ts b/test/sql/container.spec.ts
index 6b801c817..7d5342ca6 100644
--- a/test/sql/container.spec.ts
+++ b/test/sql/container.spec.ts
@@ -100,11 +100,13 @@ describe("Collection Add and Delete SQL spec", () => {
// click delete
await frame.click('input[data-test="deleteDatabase"]');
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 });
await expect(page).not.toMatchElement(`div[data-test="${dbId}"]`);
} 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}.jpg` });
+ await page.screenshot({ path: `failed-${testName}.jpg` });
throw error;
}
});
diff --git a/test/tables/container.spec.ts b/test/tables/container.spec.ts
new file mode 100644
index 000000000..eb9de8e96
--- /dev/null
+++ b/test/tables/container.spec.ts
@@ -0,0 +1,71 @@
+import "expect-puppeteer";
+import { generateUniqueName, login } from "../utils/shared";
+
+jest.setTimeout(300000);
+const LOADING_STATE_DELAY = 2500;
+const RENDER_DELAY = 1000;
+
+describe("Collection Add and Delete Tables spec", () => {
+ it("creates a collection", async () => {
+ try {
+ const tableId = generateUniqueName("TestTable");
+ const frame = await login(process.env.TABLES_CONNECTION_STRING);
+
+ // create new collection
+ 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"]');
+
+ // type database id
+ await frame.waitFor('input[data-test="addCollection-newDatabaseId"]');
+ const dbInput = await frame.$('input[data-test="addCollection-newDatabaseId"]');
+ await dbInput.press("Backspace");
+ await dbInput.type(tableId);
+
+ // click submit
+ await frame.waitFor("#submitBtnAddCollection");
+ await frame.click("#submitBtnAddCollection");
+
+ // validate created
+ // open database menu
+ await frame.waitForSelector('div[class="splashScreen"] > div[class="title"]', { visible: true });
+
+ await frame.waitFor(`div[data-test="TablesDB"]`), { visible: true };
+ await frame.waitFor(LOADING_STATE_DELAY);
+ await frame.waitFor(`div[data-test="TablesDB"]`), { visible: true };
+ await frame.waitFor(LOADING_STATE_DELAY);
+ const button = await frame.$(`div[data-test="TablesDB"]`);
+ await button.focus();
+ await button.asElement().click();
+ await frame.waitFor(`div[data-test="${tableId}"]`, { visible: true });
+
+ // delete container
+
+ // click context menu for container
+ await frame.waitFor(`div[data-test="${tableId}"] > div > button`, { visible: true });
+ await frame.click(`div[data-test="${tableId}"] > div > button`);
+
+ // click delete container
+ await frame.waitFor(RENDER_DELAY);
+ await frame.waitFor('span[class="treeComponentMenuItemLabel deleteCollectionMenuItemLabel"]');
+ await frame.click('span[class="treeComponentMenuItemLabel deleteCollectionMenuItemLabel"]');
+
+ // confirm delete container
+ await frame.waitFor('input[data-test="confirmCollectionId"]', { visible: true });
+ await frame.type('input[data-test="confirmCollectionId"]', tableId);
+
+ // click delete
+ await frame.waitFor('input[data-test="deleteCollection"]', { visible: true });
+ await frame.click('input[data-test="deleteCollection"]');
+ 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="${tableId}"]`);
+ } catch (error) {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ const testName = (expect as any).getState().currentTestName;
+ await page.screenshot({ path: `failed-${testName}.jpg` });
+ throw error;
+ }
+ });
+});
diff --git a/test/utils/shared.ts b/test/utils/shared.ts
index 458899700..3960a936d 100644
--- a/test/utils/shared.ts
+++ b/test/utils/shared.ts
@@ -3,7 +3,7 @@ import { Frame } from "puppeteer";
export async function login(connectionString: string): Promise {
const prodUrl = "https://localhost:1234/hostedExplorer.html";
- page.goto(prodUrl);
+ page.goto(prodUrl, { waitUntil: "networkidle2" });
// log in with connection string
const handle = await page.waitForSelector("iframe");