mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-01-23 19:54:08 +00:00
Compare commits
14 Commits
master
...
users/aisa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3501e7dc8 | ||
|
|
574769ba89 | ||
|
|
a5e7b53783 | ||
|
|
8027e5899d | ||
|
|
c5da4eb25b | ||
|
|
fd9cb0026c | ||
|
|
4a5ed80c6c | ||
|
|
544ac890c6 | ||
|
|
094fd4d6f4 | ||
|
|
7665f60fdd | ||
|
|
561eb6d1fa | ||
|
|
d24400198d | ||
|
|
d32ccfef13 | ||
|
|
3f01ce5ff0 |
23
test/fx.ts
23
test/fx.ts
@@ -63,6 +63,9 @@ export const TEST_MANUAL_THROUGHPUT_RU_2K = 2000;
|
|||||||
export const ONE_MINUTE_MS: number = 60 * 1000;
|
export const ONE_MINUTE_MS: number = 60 * 1000;
|
||||||
|
|
||||||
function tryGetStandardName(accountType: TestAccount) {
|
function tryGetStandardName(accountType: TestAccount) {
|
||||||
|
if (accountType === TestAccount.MongoReadonly) {
|
||||||
|
return "aisayas-e2e-mongo-readonly";
|
||||||
|
}
|
||||||
if (process.env.DE_TEST_ACCOUNT_PREFIX) {
|
if (process.env.DE_TEST_ACCOUNT_PREFIX) {
|
||||||
const actualPrefix = process.env.DE_TEST_ACCOUNT_PREFIX.endsWith("-")
|
const actualPrefix = process.env.DE_TEST_ACCOUNT_PREFIX.endsWith("-")
|
||||||
? process.env.DE_TEST_ACCOUNT_PREFIX
|
? process.env.DE_TEST_ACCOUNT_PREFIX
|
||||||
@@ -378,9 +381,11 @@ type PanelOpenOptions = {
|
|||||||
|
|
||||||
export enum CommandBarButton {
|
export enum CommandBarButton {
|
||||||
Save = "Save",
|
Save = "Save",
|
||||||
|
Delete = "Delete",
|
||||||
Execute = "Execute",
|
Execute = "Execute",
|
||||||
ExecuteQuery = "Execute Query",
|
ExecuteQuery = "Execute Query",
|
||||||
UploadItem = "Upload Item",
|
UploadItem = "Upload Item",
|
||||||
|
NewDocument = "New Document",
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Helper class that provides locator methods for DataExplorer components, on top of a Frame */
|
/** Helper class that provides locator methods for DataExplorer components, on top of a Frame */
|
||||||
@@ -478,7 +483,7 @@ export class DataExplorer {
|
|||||||
return await this.waitForNode(`${databaseId}/${containerId}/Documents`);
|
return await this.waitForNode(`${databaseId}/${containerId}/Documents`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async waitForCommandBarButton(label: string, timeout?: number): Promise<Locator> {
|
async waitForCommandBarButton(label: CommandBarButton, timeout?: number): Promise<Locator> {
|
||||||
const commandBar = this.commandBarButton(label);
|
const commandBar = this.commandBarButton(label);
|
||||||
await commandBar.waitFor({ state: "visible", timeout });
|
await commandBar.waitFor({ state: "visible", timeout });
|
||||||
return commandBar;
|
return commandBar;
|
||||||
@@ -515,14 +520,14 @@ export class DataExplorer {
|
|||||||
const containerNode = await this.waitForContainerNode(context.database.id, context.container.id);
|
const containerNode = await this.waitForContainerNode(context.database.id, context.container.id);
|
||||||
await containerNode.expand();
|
await containerNode.expand();
|
||||||
|
|
||||||
// refresh tree to remove deleted database
|
// // refresh tree to remove deleted database
|
||||||
const consoleMessages = await this.getNotificationConsoleMessages();
|
// const consoleMessages = await this.getNotificationConsoleMessages();
|
||||||
const refreshButton = this.frame.getByTestId("Sidebar/RefreshButton");
|
// const refreshButton = this.frame.getByTestId("Sidebar/RefreshButton");
|
||||||
await refreshButton.click();
|
// await refreshButton.click();
|
||||||
await expect(consoleMessages).toContainText("Successfully refreshed databases", {
|
// await expect(consoleMessages).toContainText("Successfully refreshed databases", {
|
||||||
timeout: ONE_MINUTE_MS,
|
// timeout: ONE_MINUTE_MS,
|
||||||
});
|
// });
|
||||||
await this.collapseNotificationConsole();
|
// await this.collapseNotificationConsole();
|
||||||
|
|
||||||
const scaleAndSettingsButton = this.frame.getByTestId(
|
const scaleAndSettingsButton = this.frame.getByTestId(
|
||||||
`TreeNode:${context.database.id}/${context.container.id}/Scale & Settings`,
|
`TreeNode:${context.database.id}/${context.container.id}/Scale & Settings`,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { expect, test } from "@playwright/test";
|
import { expect, test } from "@playwright/test";
|
||||||
|
|
||||||
import { setupCORSBypass } from "../CORSBypass";
|
import { setupCORSBypass } from "../CORSBypass";
|
||||||
import { DataExplorer, DocumentsTab, TestAccount } from "../fx";
|
import { CommandBarButton, DataExplorer, DocumentsTab, TestAccount } from "../fx";
|
||||||
import { retry, serializeMongoToJson, setPartitionKeys } from "../testData";
|
import { retry, serializeMongoToJson, setPartitionKeys } from "../testData";
|
||||||
import { documentTestCases } from "./testCases";
|
import { documentTestCases } from "./testCases";
|
||||||
|
|
||||||
@@ -26,6 +26,8 @@ for (const { name, databaseId, containerId, documents } of documentTestCases) {
|
|||||||
await documentsTab.documentsFilter.waitFor();
|
await documentsTab.documentsFilter.waitFor();
|
||||||
await documentsTab.documentsListPane.waitFor();
|
await documentsTab.documentsListPane.waitFor();
|
||||||
await expect(documentsTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 });
|
await expect(documentsTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 });
|
||||||
|
|
||||||
|
await explorer.expandNotificationConsole();
|
||||||
});
|
});
|
||||||
test.afterEach(async ({ page }) => {
|
test.afterEach(async ({ page }) => {
|
||||||
await page.unrouteAll({ behavior: "ignoreErrors" });
|
await page.unrouteAll({ behavior: "ignoreErrors" });
|
||||||
@@ -54,26 +56,40 @@ for (const { name, databaseId, containerId, documents } of documentTestCases) {
|
|||||||
await expect(span).toBeVisible();
|
await expect(span).toBeVisible();
|
||||||
|
|
||||||
await span.click();
|
await span.click();
|
||||||
|
expect(await documentsTab.resultsEditor.text()).toContain(docId);
|
||||||
|
|
||||||
let newDocumentId;
|
let newDocumentId;
|
||||||
|
let retryCount = 0;
|
||||||
await retry(async () => {
|
await retry(async () => {
|
||||||
const newDocumentButton = await explorer.waitForCommandBarButton("New Document", 5000);
|
try {
|
||||||
await expect(newDocumentButton).toBeVisible();
|
const newDocumentButton = await explorer.waitForCommandBarButton(CommandBarButton.NewDocument, 5000);
|
||||||
await expect(newDocumentButton).toBeEnabled();
|
await expect(newDocumentButton).toBeVisible();
|
||||||
await newDocumentButton.click();
|
await expect(newDocumentButton).toBeEnabled();
|
||||||
|
await newDocumentButton.click();
|
||||||
|
console.log(`DEBUG: Clicked New Document button - retryCount=${retryCount}`);
|
||||||
|
await expect(documentsTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 });
|
||||||
|
|
||||||
await expect(documentsTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 });
|
newDocumentId = `${Date.now().toString()}-delete`;
|
||||||
|
|
||||||
newDocumentId = `${Date.now().toString()}-delete`;
|
const newDocument = {
|
||||||
|
_id: newDocumentId,
|
||||||
|
...setPartitionKeys(partitionKeys || []),
|
||||||
|
};
|
||||||
|
|
||||||
const newDocument = {
|
await documentsTab.resultsEditor.setText(JSON.stringify(newDocument));
|
||||||
_id: newDocumentId,
|
const saveButton = await explorer.waitForCommandBarButton(CommandBarButton.Save, 5000);
|
||||||
...setPartitionKeys(partitionKeys || []),
|
await saveButton.click({ timeout: 5000 });
|
||||||
};
|
console.log(`DEBUG: Clicked Save button - retryCount=${retryCount}`);
|
||||||
|
|
||||||
await documentsTab.resultsEditor.setText(JSON.stringify(newDocument));
|
await expect(saveButton).toBeHidden({ timeout: 5000 });
|
||||||
const saveButton = await explorer.waitForCommandBarButton("Save", 5000);
|
} catch (err) {
|
||||||
await saveButton.click({ timeout: 5000 });
|
retryCount++;
|
||||||
await expect(saveButton).toBeHidden({ timeout: 5000 });
|
console.warn(
|
||||||
|
`DEBUG: Attempt ${retryCount} to create new document from ${docId} failed: ${(err as Error).message}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
}, 3);
|
}, 3);
|
||||||
|
|
||||||
await documentsTab.setFilter(`{_id: "${newDocumentId}"}`);
|
await documentsTab.setFilter(`{_id: "${newDocumentId}"}`);
|
||||||
@@ -84,7 +100,7 @@ for (const { name, databaseId, containerId, documents } of documentTestCases) {
|
|||||||
await newSpan.click();
|
await newSpan.click();
|
||||||
await expect(documentsTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 });
|
await expect(documentsTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 });
|
||||||
|
|
||||||
const deleteButton = await explorer.waitForCommandBarButton("Delete", 5000);
|
const deleteButton = await explorer.waitForCommandBarButton(CommandBarButton.Delete, 5000);
|
||||||
await deleteButton.click();
|
await deleteButton.click();
|
||||||
|
|
||||||
const deleteDialogButton = await explorer.waitForDialogButton("Delete", 5000);
|
const deleteDialogButton = await explorer.waitForDialogButton("Delete", 5000);
|
||||||
|
|||||||
@@ -136,9 +136,7 @@ test.describe.serial("Upload Item", () => {
|
|||||||
if (existsSync(uploadDocumentDirPath)) {
|
if (existsSync(uploadDocumentDirPath)) {
|
||||||
rmdirSync(uploadDocumentDirPath);
|
rmdirSync(uploadDocumentDirPath);
|
||||||
}
|
}
|
||||||
if (!process.env.CI) {
|
await context?.dispose();
|
||||||
await context?.dispose();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test.afterEach("Close Upload Items panel if still open", async () => {
|
test.afterEach("Close Upload Items panel if still open", async () => {
|
||||||
|
|||||||
@@ -30,12 +30,9 @@ test.beforeEach("Open new query tab", async ({ page }) => {
|
|||||||
await explorer.frame.getByTestId("NotificationConsole/Contents").waitFor();
|
await explorer.frame.getByTestId("NotificationConsole/Contents").waitFor();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Delete database only if not running in CI
|
test.afterAll("Delete Test Database", async () => {
|
||||||
if (!process.env.CI) {
|
await context?.dispose();
|
||||||
test.afterAll("Delete Test Database", async () => {
|
});
|
||||||
await context?.dispose();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
test("Query results", async () => {
|
test("Query results", async () => {
|
||||||
// Run the query and verify the results
|
// Run the query and verify the results
|
||||||
|
|||||||
@@ -23,12 +23,9 @@ test.describe("Change Partition Key", () => {
|
|||||||
await PartitionKeyTab.click();
|
await PartitionKeyTab.click();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Delete database only if not running in CI
|
test.afterEach("Delete Test Database", async () => {
|
||||||
if (!process.env.CI) {
|
await context?.dispose();
|
||||||
test.afterEach("Delete Test Database", async () => {
|
});
|
||||||
await context?.dispose();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
test("Change partition key path", async ({ page }) => {
|
test("Change partition key path", async ({ page }) => {
|
||||||
await expect(explorer.frame.getByText("/partitionKey")).toBeVisible();
|
await expect(explorer.frame.getByText("/partitionKey")).toBeVisible();
|
||||||
|
|||||||
@@ -118,7 +118,5 @@ async function openScaleTab(browser: Browser): Promise<SetupResult> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function cleanup({ context }: Partial<SetupResult>) {
|
async function cleanup({ context }: Partial<SetupResult>) {
|
||||||
if (!process.env.CI) {
|
await context?.dispose();
|
||||||
await context?.dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,12 +17,9 @@ test.describe("Settings under Scale & Settings", () => {
|
|||||||
await settingsTab.click();
|
await settingsTab.click();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Delete database only if not running in CI
|
test.afterAll("Delete Test Database", async () => {
|
||||||
if (!process.env.CI) {
|
await context?.dispose();
|
||||||
test.afterAll("Delete Test Database", async () => {
|
});
|
||||||
await context?.dispose();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
test("Update TTL to On (no default)", async () => {
|
test("Update TTL to On (no default)", async () => {
|
||||||
const ttlOnNoDefaultRadioButton = explorer.frame.getByRole("radio", { name: "ttl-on-no-default-option" });
|
const ttlOnNoDefaultRadioButton = explorer.frame.getByRole("radio", { name: "ttl-on-no-default-option" });
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ test.describe("Stored Procedures", () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Execute stored procedure
|
// Execute stored procedure
|
||||||
const executeButton = explorer.commandBarButton(CommandBarButton.Execute);
|
const executeButton = explorer.commandBarButton(CommandBarButton.Execute).first();
|
||||||
await executeButton.click();
|
await executeButton.click();
|
||||||
const executeSidePanelButton = explorer.frame.getByTestId("Panel/OkButton");
|
const executeSidePanelButton = explorer.frame.getByTestId("Panel/OkButton");
|
||||||
await executeSidePanelButton.click();
|
await executeSidePanelButton.click();
|
||||||
|
|||||||
@@ -26,11 +26,9 @@ test.describe("Triggers", () => {
|
|||||||
explorer = await DataExplorer.open(page, TestAccount.SQL);
|
explorer = await DataExplorer.open(page, TestAccount.SQL);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!process.env.CI) {
|
test.afterAll("Delete Test Database", async () => {
|
||||||
test.afterAll("Delete Test Database", async () => {
|
await context?.dispose();
|
||||||
await context?.dispose();
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
test("Add and delete trigger", async ({ page }, testInfo) => {
|
test("Add and delete trigger", async ({ page }, testInfo) => {
|
||||||
// Open container context menu and click New Trigger
|
// Open container context menu and click New Trigger
|
||||||
|
|||||||
@@ -19,11 +19,9 @@ test.describe("User Defined Functions", () => {
|
|||||||
explorer = await DataExplorer.open(page, TestAccount.SQL);
|
explorer = await DataExplorer.open(page, TestAccount.SQL);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!process.env.CI) {
|
test.afterAll("Delete Test Database", async () => {
|
||||||
test.afterAll("Delete Test Database", async () => {
|
await context?.dispose();
|
||||||
await context?.dispose();
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
test("Add, execute, and delete user defined function", async ({ page }, testInfo) => {
|
test("Add, execute, and delete user defined function", async ({ page }, testInfo) => {
|
||||||
// Open container context menu and click New UDF
|
// Open container context menu and click New UDF
|
||||||
|
|||||||
Reference in New Issue
Block a user