mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-18 16:31:31 +00:00
End to end testcase for mongoDb index policy (#426)
* 'update for index policy' * input * 'refactor for ci/cd' * 'refactor for ci/cd' * no message * 'refractor' * 'format change' * added changes * "refactor" * ‘test lint’ * "format" * “push setting back” * ‘refractor’ * Update test/utils/shared.ts Co-authored-by: Steve Faulkner <southpolesteve@gmail.com> Co-authored-by: Srinath Narayanan <srnara@microsoft.com> Co-authored-by: Steve Faulkner <southpolesteve@gmail.com>
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import crypto from "crypto";
|
||||
import { Frame } from "puppeteer";
|
||||
|
||||
const LOADING_STATE_DELAY = 3000;
|
||||
const CREATE_DELAY = 10000;
|
||||
|
||||
export async function login(connectionString: string): Promise<Frame> {
|
||||
const prodUrl = process.env.DATA_EXPLORER_ENDPOINT;
|
||||
await page.goto(prodUrl);
|
||||
@@ -22,3 +25,49 @@ export async function login(connectionString: string): Promise<Frame> {
|
||||
export function generateUniqueName(baseName = "", length = 4): string {
|
||||
return `${baseName}${crypto.randomBytes(length).toString("hex")}`;
|
||||
}
|
||||
|
||||
export async function createDatabase(frame: Frame) {
|
||||
const dbId = generateUniqueName("db");
|
||||
const collectionId = generateUniqueName("col");
|
||||
const shardKey = generateUniqueName();
|
||||
// create new collection
|
||||
await frame.waitFor('button[data-test="New Collection"]', { visible: true });
|
||||
await frame.click('button[data-test="New Collection"]');
|
||||
|
||||
// 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"]');
|
||||
await frame.click('input[data-test="addCollectionPane-databaseSharedThroughput"]');
|
||||
|
||||
// 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(dbId);
|
||||
|
||||
// type collection id
|
||||
await frame.waitFor('input[data-test="addCollection-collectionId"]');
|
||||
const input = await frame.$('input[data-test="addCollection-collectionId"]');
|
||||
await input.press("Backspace");
|
||||
await input.type(collectionId);
|
||||
|
||||
// type partition key value
|
||||
await frame.waitFor('input[data-test="addCollection-partitionKeyValue"]');
|
||||
const keyInput = await frame.$('input[data-test="addCollection-partitionKeyValue"]');
|
||||
await keyInput.press("Backspace");
|
||||
await keyInput.type(shardKey);
|
||||
|
||||
// click submit
|
||||
await frame.waitFor("#submitBtnAddCollection");
|
||||
await frame.click("#submitBtnAddCollection");
|
||||
}
|
||||
|
||||
export async function onClickSaveButton(frame: Frame) {
|
||||
await frame.waitFor(`button[data-test="Save"]`), { visible: true };
|
||||
await frame.waitFor(LOADING_STATE_DELAY);
|
||||
await frame.click(`button[data-test="Save"]`);
|
||||
await frame.waitFor(CREATE_DELAY);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user