2020-09-09 18:18:27 +01:00
|
|
|
import "expect-puppeteer";
|
2020-09-30 21:42:33 +01:00
|
|
|
import { generateUniqueName, login } from "../utils/shared";
|
2020-09-09 18:18:27 +01:00
|
|
|
|
|
|
|
jest.setTimeout(300000);
|
2020-09-30 21:42:33 +01:00
|
|
|
const LOADING_STATE_DELAY = 2500;
|
|
|
|
const RENDER_DELAY = 1000;
|
2020-09-09 18:18:27 +01:00
|
|
|
|
2020-09-23 21:18:05 +01:00
|
|
|
describe("Collection Add and Delete SQL spec", () => {
|
|
|
|
it("creates a collection", async () => {
|
2020-09-09 18:18:27 +01:00
|
|
|
try {
|
2020-09-30 21:42:33 +01:00
|
|
|
const dbId = generateUniqueName("TestDatabase");
|
|
|
|
const collectionId = generateUniqueName("TestCollection");
|
|
|
|
const sharedKey = generateUniqueName("SharedKey");
|
|
|
|
const frame = await login(process.env.PORTAL_RUNNER_CONNECTION_STRING);
|
2020-09-09 18:18:27 +01:00
|
|
|
|
|
|
|
// create new collection
|
|
|
|
await frame.waitFor('button[data-test="New Container"]', { visible: true });
|
|
|
|
await frame.waitForSelector('div[class="splashScreen"] > div[class="title"]', { visible: true });
|
|
|
|
await frame.click('button[data-test="New Container"]');
|
2020-09-23 21:18:05 +01:00
|
|
|
|
2020-09-09 18:18:27 +01:00
|
|
|
// check new database
|
|
|
|
await frame.waitFor('input[data-test="addCollection-createNewDatabase"]');
|
|
|
|
await frame.click('input[data-test="addCollection-createNewDatabase"]');
|
|
|
|
|
|
|
|
// check shared throughput
|
|
|
|
await frame.waitFor('input[data-test="addCollectionPane-databaseSharedThroughput"]');
|
2020-09-23 21:18:05 +01:00
|
|
|
await frame.click('input[data-test="addCollectionPane-databaseSharedThroughput"]');
|
2020-09-09 18:18:27 +01:00
|
|
|
|
|
|
|
// type database id
|
|
|
|
await frame.waitFor('input[data-test="addCollection-newDatabaseId"]');
|
2020-09-23 21:18:05 +01:00
|
|
|
await frame.type('input[data-test="addCollection-newDatabaseId"]', dbId);
|
2020-09-09 18:18:27 +01:00
|
|
|
|
|
|
|
// type collection id
|
|
|
|
await frame.waitFor('input[data-test="addCollection-collectionId"]');
|
2020-09-23 21:18:05 +01:00
|
|
|
await frame.type('input[data-test="addCollection-collectionId"]', collectionId);
|
2020-09-09 18:18:27 +01:00
|
|
|
|
|
|
|
// type partition key value
|
|
|
|
await frame.waitFor('input[data-test="addCollection-partitionKeyValue"]');
|
|
|
|
await frame.type('input[data-test="addCollection-partitionKeyValue"]', sharedKey);
|
|
|
|
|
|
|
|
// click submit
|
2020-09-23 21:18:05 +01:00
|
|
|
await frame.waitFor("#submitBtnAddCollection");
|
|
|
|
await frame.click("#submitBtnAddCollection");
|
2020-09-09 18:18:27 +01:00
|
|
|
|
|
|
|
// validate created
|
|
|
|
// open database menu
|
|
|
|
await frame.waitFor(`span[title="${dbId}"]`);
|
|
|
|
await frame.waitForSelector('div[class="splashScreen"] > div[class="title"]', { visible: true });
|
|
|
|
|
2020-09-30 21:42:33 +01:00
|
|
|
await frame.waitFor(`div[data-test="${dbId}"]`), { visible: true };
|
2020-09-09 18:18:27 +01:00
|
|
|
await frame.click(`div[data-test="${dbId}"]`);
|
2020-09-30 21:42:33 +01:00
|
|
|
await frame.waitFor(RENDER_DELAY);
|
|
|
|
await frame.waitFor(`div[data-test="${collectionId}"]`, { visible: true });
|
2020-09-23 21:18:05 +01:00
|
|
|
|
2020-09-09 18:18:27 +01:00
|
|
|
// delete container
|
|
|
|
|
|
|
|
// click context menu for container
|
2020-09-19 00:00:21 +01:00
|
|
|
await frame.waitFor(`div[data-test="${collectionId}"] > div > button`, { visible: true });
|
2020-09-09 18:18:27 +01:00
|
|
|
await frame.click(`div[data-test="${collectionId}"] > div > button`);
|
2020-09-23 21:18:05 +01:00
|
|
|
|
2020-09-09 18:18:27 +01:00
|
|
|
// click delete container
|
2020-09-30 21:42:33 +01:00
|
|
|
await frame.waitFor(RENDER_DELAY);
|
|
|
|
await frame.waitFor('span[class="treeComponentMenuItemLabel deleteCollectionMenuItemLabel"]');
|
2020-09-19 00:00:21 +01:00
|
|
|
await frame.click('span[class="treeComponentMenuItemLabel deleteCollectionMenuItemLabel"]');
|
2020-09-09 18:18:27 +01:00
|
|
|
|
|
|
|
// confirm delete container
|
2020-09-23 21:18:05 +01:00
|
|
|
await frame.waitFor('input[data-test="confirmCollectionId"]', { visible: true });
|
2020-09-09 18:18:27 +01:00
|
|
|
await frame.type('input[data-test="confirmCollectionId"]', collectionId.trim());
|
|
|
|
|
|
|
|
// click delete
|
2020-09-23 21:18:05 +01:00
|
|
|
await frame.waitFor('input[data-test="deleteCollection"]', { visible: true });
|
2020-09-09 18:18:27 +01:00
|
|
|
await frame.click('input[data-test="deleteCollection"]');
|
2020-09-30 21:42:33 +01:00
|
|
|
await frame.waitFor(LOADING_STATE_DELAY);
|
2020-09-09 18:18:27 +01:00
|
|
|
await frame.waitForSelector('div[class="splashScreen"] > div[class="title"]', { visible: true });
|
|
|
|
|
|
|
|
await expect(page).not.toMatchElement(`div[data-test="${collectionId}"]`);
|
|
|
|
|
|
|
|
// click context menu for database
|
|
|
|
await frame.waitFor(`div[data-test="${dbId}"] > div > button`);
|
|
|
|
const button = await frame.$(`div[data-test="${dbId}"] > div > button`);
|
|
|
|
await button.focus();
|
|
|
|
await button.asElement().click();
|
|
|
|
|
|
|
|
// click delete database
|
2020-09-19 00:00:21 +01:00
|
|
|
await frame.waitFor('span[class="treeComponentMenuItemLabel deleteDatabaseMenuItemLabel"]');
|
|
|
|
await frame.click('span[class="treeComponentMenuItemLabel deleteDatabaseMenuItemLabel"]');
|
2020-09-09 18:18:27 +01:00
|
|
|
|
|
|
|
// confirm delete database
|
2020-09-30 21:42:33 +01:00
|
|
|
await frame.waitForSelector('input[data-test="confirmDatabaseId"]', { visible: true });
|
|
|
|
await frame.waitFor(RENDER_DELAY);
|
2020-09-09 18:18:27 +01:00
|
|
|
await frame.type('input[data-test="confirmDatabaseId"]', dbId.trim());
|
|
|
|
|
|
|
|
// click delete
|
|
|
|
await frame.click('input[data-test="deleteDatabase"]');
|
|
|
|
await frame.waitForSelector('div[class="splashScreen"] > div[class="title"]', { visible: true });
|
|
|
|
await expect(page).not.toMatchElement(`div[data-test="${dbId}"]`);
|
|
|
|
} catch (error) {
|
2020-09-22 21:21:57 +01:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2020-09-23 21:18:05 +01:00
|
|
|
const testName = (expect as any).getState().currentTestName;
|
|
|
|
await page.screenshot({ path: `Test Failed ${testName}.jpg` });
|
2020-09-09 18:18:27 +01:00
|
|
|
throw error;
|
2020-09-23 21:18:05 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|