Comment out most tests.

This commit is contained in:
Jade Welton
2026-07-08 09:45:37 -07:00
parent 27ffa7208b
commit 89f9e99472
23 changed files with 2629 additions and 2630 deletions
+43 -44
View File
@@ -1,52 +1,51 @@
import { expect, test } from "@playwright/test"; // import { expect, test } from "@playwright/test";
import { DataExplorer, TEST_AUTOSCALE_THROUGHPUT_RU, TestAccount, generateUniqueName } from "../fx"; // import { DataExplorer, TEST_AUTOSCALE_THROUGHPUT_RU, TestAccount, generateUniqueName } from "../fx";
test("Cassandra keyspace and table CRUD", async ({ page }) => { // test("Cassandra keyspace and table CRUD", async ({ page }) => {
test.skip(); // const keyspaceId = generateUniqueName("db");
const keyspaceId = generateUniqueName("db"); // const tableId = "testtable"; // A unique table name isn't needed because the keyspace is unique
const tableId = "testtable"; // A unique table name isn't needed because the keyspace is unique
const explorer = await DataExplorer.open(page, TestAccount.Cassandra); // const explorer = await DataExplorer.open(page, TestAccount.Cassandra);
const newTableButton = await explorer.globalCommandButton("New Table"); // const newTableButton = await explorer.globalCommandButton("New Table");
await newTableButton.click(); // await newTableButton.click();
await explorer.whilePanelOpen( // await explorer.whilePanelOpen(
"Add Table", // "Add Table",
async (panel, okButton) => { // async (panel, okButton) => {
await panel.getByPlaceholder("Type a new keyspace id").fill(keyspaceId); // await panel.getByPlaceholder("Type a new keyspace id").fill(keyspaceId);
await panel.getByPlaceholder("Enter table Id").fill(tableId); // await panel.getByPlaceholder("Enter table Id").fill(tableId);
await panel.getByTestId("autoscaleRUInput").fill(TEST_AUTOSCALE_THROUGHPUT_RU.toString()); // await panel.getByTestId("autoscaleRUInput").fill(TEST_AUTOSCALE_THROUGHPUT_RU.toString());
await okButton.click(); // await okButton.click();
}, // },
{ closeTimeout: 5 * 60 * 1000 }, // { closeTimeout: 5 * 60 * 1000 },
); // );
const keyspaceNode = await explorer.waitForNode(keyspaceId); // const keyspaceNode = await explorer.waitForNode(keyspaceId);
const tableNode = await explorer.waitForContainerNode(keyspaceId, tableId); // const tableNode = await explorer.waitForContainerNode(keyspaceId, tableId);
await tableNode.openContextMenu(); // await tableNode.openContextMenu();
await tableNode.contextMenuItem("Delete Table").click(); // await tableNode.contextMenuItem("Delete Table").click();
await explorer.whilePanelOpen( // await explorer.whilePanelOpen(
"Delete Table", // "Delete Table",
async (panel, okButton) => { // async (panel, okButton) => {
await panel.getByRole("textbox", { name: "Confirm by typing the table id" }).fill(tableId); // await panel.getByRole("textbox", { name: "Confirm by typing the table id" }).fill(tableId);
await okButton.click(); // await okButton.click();
}, // },
{ closeTimeout: 5 * 60 * 1000 }, // { closeTimeout: 5 * 60 * 1000 },
); // );
await expect(tableNode.element).not.toBeAttached(); // await expect(tableNode.element).not.toBeAttached();
await keyspaceNode.openContextMenu(); // await keyspaceNode.openContextMenu();
await keyspaceNode.contextMenuItem("Delete Keyspace").click(); // await keyspaceNode.contextMenuItem("Delete Keyspace").click();
await explorer.whilePanelOpen( // await explorer.whilePanelOpen(
"Delete Keyspace", // "Delete Keyspace",
async (panel, okButton) => { // async (panel, okButton) => {
await panel.getByRole("textbox", { name: "Confirm by typing the Keyspace id" }).fill(keyspaceId); // await panel.getByRole("textbox", { name: "Confirm by typing the Keyspace id" }).fill(keyspaceId);
await okButton.click(); // await okButton.click();
}, // },
{ closeTimeout: 5 * 60 * 1000 }, // { closeTimeout: 5 * 60 * 1000 },
); // );
await expect(keyspaceNode.element).not.toBeAttached(); // await expect(keyspaceNode.element).not.toBeAttached();
}); // });
+46 -46
View File
@@ -1,54 +1,54 @@
import { expect, test } from "@playwright/test"; // import { expect, test } from "@playwright/test";
import { DataExplorer, TEST_AUTOSCALE_THROUGHPUT_RU, TestAccount, generateUniqueName } from "../fx"; // import { DataExplorer, TEST_AUTOSCALE_THROUGHPUT_RU, TestAccount, generateUniqueName } from "../fx";
test("Gremlin graph CRUD", async ({ page }) => { // test("Gremlin graph CRUD", async ({ page }) => {
test.skip(); // test.skip();
const databaseId = generateUniqueName("db"); // const databaseId = generateUniqueName("db");
const graphId = "testgraph"; // A unique graph name isn't needed because the database is unique // const graphId = "testgraph"; // A unique graph name isn't needed because the database is unique
const explorer = await DataExplorer.open(page, TestAccount.Gremlin); // const explorer = await DataExplorer.open(page, TestAccount.Gremlin);
// Create new database and graph // // Create new database and graph
const newGraphButton = await explorer.globalCommandButton("New Graph"); // const newGraphButton = await explorer.globalCommandButton("New Graph");
await newGraphButton.click(); // await newGraphButton.click();
await explorer.whilePanelOpen( // await explorer.whilePanelOpen(
"New Graph", // "New Graph",
async (panel, okButton) => { // async (panel, okButton) => {
await panel.getByPlaceholder("Type a new database id").fill(databaseId); // await panel.getByPlaceholder("Type a new database id").fill(databaseId);
await panel.getByRole("textbox", { name: "Graph id, Example Graph1" }).fill(graphId); // await panel.getByRole("textbox", { name: "Graph id, Example Graph1" }).fill(graphId);
await panel.getByRole("textbox", { name: "Partition key" }).fill("/pk"); // await panel.getByRole("textbox", { name: "Partition key" }).fill("/pk");
await panel.getByTestId("autoscaleRUInput").fill(TEST_AUTOSCALE_THROUGHPUT_RU.toString()); // await panel.getByTestId("autoscaleRUInput").fill(TEST_AUTOSCALE_THROUGHPUT_RU.toString());
await okButton.click(); // await okButton.click();
}, // },
{ closeTimeout: 5 * 60 * 1000 }, // { closeTimeout: 5 * 60 * 1000 },
); // );
const databaseNode = await explorer.waitForNode(databaseId); // const databaseNode = await explorer.waitForNode(databaseId);
const graphNode = await explorer.waitForContainerNode(databaseId, graphId); // const graphNode = await explorer.waitForContainerNode(databaseId, graphId);
await graphNode.openContextMenu(); // await graphNode.openContextMenu();
await graphNode.contextMenuItem("Delete Graph").click(); // await graphNode.contextMenuItem("Delete Graph").click();
await explorer.whilePanelOpen( // await explorer.whilePanelOpen(
"Delete Graph", // "Delete Graph",
async (panel, okButton) => { // async (panel, okButton) => {
await panel.getByRole("textbox", { name: "Confirm by typing the graph id" }).fill(graphId); // await panel.getByRole("textbox", { name: "Confirm by typing the graph id" }).fill(graphId);
await okButton.click(); // await okButton.click();
}, // },
{ closeTimeout: 5 * 60 * 1000 }, // { closeTimeout: 5 * 60 * 1000 },
); // );
await expect(graphNode.element).not.toBeAttached(); // await expect(graphNode.element).not.toBeAttached();
await databaseNode.openContextMenu(); // await databaseNode.openContextMenu();
await databaseNode.contextMenuItem("Delete Database").click(); // await databaseNode.contextMenuItem("Delete Database").click();
await explorer.whilePanelOpen( // await explorer.whilePanelOpen(
"Delete Database", // "Delete Database",
async (panel, okButton) => { // async (panel, okButton) => {
await panel.getByRole("textbox", { name: "Confirm by typing the Database id" }).fill(databaseId); // await panel.getByRole("textbox", { name: "Confirm by typing the Database id" }).fill(databaseId);
await okButton.click(); // await okButton.click();
}, // },
{ closeTimeout: 5 * 60 * 1000 }, // { closeTimeout: 5 * 60 * 1000 },
); // );
await expect(databaseNode.element).not.toBeAttached(); // await expect(databaseNode.element).not.toBeAttached();
}); // });
+52 -52
View File
@@ -1,60 +1,60 @@
import { expect, test } from "@playwright/test"; // import { expect, test } from "@playwright/test";
import { DataExplorer, TEST_AUTOSCALE_THROUGHPUT_RU, TestAccount, generateUniqueName } from "../fx"; // import { DataExplorer, TEST_AUTOSCALE_THROUGHPUT_RU, TestAccount, generateUniqueName } from "../fx";
( // (
[ // [
["latest API version", TestAccount.Mongo], // ["latest API version", TestAccount.Mongo],
["3.2 API", TestAccount.Mongo32], // ["3.2 API", TestAccount.Mongo32],
] as [string, TestAccount][] // ] as [string, TestAccount][]
).forEach(([apiVersionDescription, accountType]) => { // ).forEach(([apiVersionDescription, accountType]) => {
test(`Mongo CRUD using ${apiVersionDescription}`, async ({ page }) => { // test(`Mongo CRUD using ${apiVersionDescription}`, async ({ page }) => {
test.skip(); // test.skip();
const databaseId = generateUniqueName("db"); // const databaseId = generateUniqueName("db");
const collectionId = "testcollection"; // A unique collection name isn't needed because the database is unique // const collectionId = "testcollection"; // A unique collection name isn't needed because the database is unique
const explorer = await DataExplorer.open(page, accountType); // const explorer = await DataExplorer.open(page, accountType);
const newCollectionButton = await explorer.globalCommandButton("New Collection"); // const newCollectionButton = await explorer.globalCommandButton("New Collection");
await newCollectionButton.click(); // await newCollectionButton.click();
await explorer.whilePanelOpen( // await explorer.whilePanelOpen(
"New Collection", // "New Collection",
async (panel, okButton) => { // async (panel, okButton) => {
await panel.getByPlaceholder("Type a new database id").fill(databaseId); // await panel.getByPlaceholder("Type a new database id").fill(databaseId);
await panel.getByRole("textbox", { name: "Collection id, Example Collection1" }).fill(collectionId); // await panel.getByRole("textbox", { name: "Collection id, Example Collection1" }).fill(collectionId);
await panel.getByRole("textbox", { name: "Shard key" }).fill("pk"); // await panel.getByRole("textbox", { name: "Shard key" }).fill("pk");
await panel.getByTestId("autoscaleRUInput").fill(TEST_AUTOSCALE_THROUGHPUT_RU.toString()); // await panel.getByTestId("autoscaleRUInput").fill(TEST_AUTOSCALE_THROUGHPUT_RU.toString());
await okButton.click(); // await okButton.click();
}, // },
{ closeTimeout: 5 * 60 * 1000 }, // { closeTimeout: 5 * 60 * 1000 },
); // );
const databaseNode = await explorer.waitForNode(databaseId); // const databaseNode = await explorer.waitForNode(databaseId);
const collectionNode = await explorer.waitForContainerNode(databaseId, collectionId); // const collectionNode = await explorer.waitForContainerNode(databaseId, collectionId);
await collectionNode.openContextMenu(); // await collectionNode.openContextMenu();
await collectionNode.contextMenuItem("Delete Collection").click(); // await collectionNode.contextMenuItem("Delete Collection").click();
await explorer.whilePanelOpen( // await explorer.whilePanelOpen(
"Delete Collection", // "Delete Collection",
async (panel, okButton) => { // async (panel, okButton) => {
await panel.getByRole("textbox", { name: "Confirm by typing the collection id" }).fill(collectionId); // await panel.getByRole("textbox", { name: "Confirm by typing the collection id" }).fill(collectionId);
await okButton.click(); // await okButton.click();
}, // },
{ closeTimeout: 5 * 60 * 1000 }, // { closeTimeout: 5 * 60 * 1000 },
); // );
await expect(collectionNode.element).not.toBeAttached(); // await expect(collectionNode.element).not.toBeAttached();
await databaseNode.openContextMenu(); // await databaseNode.openContextMenu();
await databaseNode.contextMenuItem("Delete Database").click(); // await databaseNode.contextMenuItem("Delete Database").click();
await explorer.whilePanelOpen( // await explorer.whilePanelOpen(
"Delete Database", // "Delete Database",
async (panel, okButton) => { // async (panel, okButton) => {
await panel.getByRole("textbox", { name: "Confirm by typing the Database id" }).fill(databaseId); // await panel.getByRole("textbox", { name: "Confirm by typing the Database id" }).fill(databaseId);
await okButton.click(); // await okButton.click();
}, // },
{ closeTimeout: 5 * 60 * 1000 }, // { closeTimeout: 5 * 60 * 1000 },
); // );
await expect(databaseNode.element).not.toBeAttached(); // await expect(databaseNode.element).not.toBeAttached();
}); // });
}); // });
+82 -82
View File
@@ -1,103 +1,103 @@
import { expect, test } from "@playwright/test"; // import { expect, test } from "@playwright/test";
import { setupCORSBypass } from "../CORSBypass"; // import { setupCORSBypass } from "../CORSBypass";
import { CommandBarButton, 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";
let explorer: DataExplorer = null!; // let explorer: DataExplorer = null!;
let documentsTab: DocumentsTab = null!; // let documentsTab: DocumentsTab = null!;
for (const { name, databaseId, containerId, documents } of documentTestCases) { // for (const { name, databaseId, containerId, documents } of documentTestCases) {
test.describe(`Test MongoRU Documents with ${name}`, () => { // test.describe(`Test MongoRU Documents with ${name}`, () => {
// test.skip(true, "Temporarily disabling all tests in this spec file"); // // test.skip(true, "Temporarily disabling all tests in this spec file");
test.beforeEach("Open documents tab", async ({ page }) => { // test.beforeEach("Open documents tab", async ({ page }) => {
await setupCORSBypass(page); // await setupCORSBypass(page);
explorer = await DataExplorer.open(page, TestAccount.MongoReadonly); // explorer = await DataExplorer.open(page, TestAccount.MongoReadonly);
const containerNode = await explorer.waitForContainerNode(databaseId, containerId); // const containerNode = await explorer.waitForContainerNode(databaseId, containerId);
await containerNode.expand(); // await containerNode.expand();
const containerMenuNode = await explorer.waitForContainerDocumentsNode(databaseId, containerId); // const containerMenuNode = await explorer.waitForContainerDocumentsNode(databaseId, containerId);
await containerMenuNode.element.click(); // await containerMenuNode.element.click();
documentsTab = explorer.documentsTab("tab0"); // documentsTab = explorer.documentsTab("tab0");
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 });
}); // });
test.afterEach(async ({ page }) => { // test.afterEach(async ({ page }) => {
await page.unrouteAll({ behavior: "ignoreErrors" }); // await page.unrouteAll({ behavior: "ignoreErrors" });
}); // });
for (const document of documents) { // for (const document of documents) {
const { documentId: docId, partitionKeys } = document; // const { documentId: docId, partitionKeys } = document;
test.describe(`Document ID: ${docId}`, () => { // test.describe(`Document ID: ${docId}`, () => {
test(`should load and view document ${docId}`, async () => { // test(`should load and view document ${docId}`, async () => {
test.skip(); // test.skip();
const span = documentsTab.documentsListPane.getByText(docId, { exact: true }).nth(0); // const span = documentsTab.documentsListPane.getByText(docId, { exact: true }).nth(0);
await span.waitFor(); // await span.waitFor();
await expect(span).toBeVisible(); // await expect(span).toBeVisible();
await span.click(); // await span.click();
await expect(documentsTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 }); // await expect(documentsTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 });
const resultText = await documentsTab.resultsEditor.text(); // const resultText = await documentsTab.resultsEditor.text();
const resultData = serializeMongoToJson(resultText!); // const resultData = serializeMongoToJson(resultText!);
expect(resultText).not.toBeNull(); // expect(resultText).not.toBeNull();
expect(resultData?._id).not.toBeNull(); // expect(resultData?._id).not.toBeNull();
expect(resultData?._id).toEqual(docId); // expect(resultData?._id).toEqual(docId);
}); // });
test(`should be able to create and delete new document from ${docId}`, async ({ page }) => { // test(`should be able to create and delete new document from ${docId}`, async ({ page }) => {
test.skip(); // test.skip();
const span = documentsTab.documentsListPane.getByText(docId, { exact: true }).nth(0); // const span = documentsTab.documentsListPane.getByText(docId, { exact: true }).nth(0);
await span.waitFor(); // await span.waitFor();
await expect(span).toBeVisible(); // await expect(span).toBeVisible();
await span.click(); // await span.click();
await page.waitForTimeout(5000); // wait for 5 seconds to ensure document is fully loaded. waitforTimeout is not recommended generally but here we are working around flakiness in the test env // await page.waitForTimeout(5000); // wait for 5 seconds to ensure document is fully loaded. waitforTimeout is not recommended generally but here we are working around flakiness in the test env
let newDocumentId; // let newDocumentId;
await retry(async () => { // await retry(async () => {
const newDocumentButton = await explorer.waitForCommandBarButton(CommandBarButton.NewDocument, 5000); // const newDocumentButton = await explorer.waitForCommandBarButton(CommandBarButton.NewDocument, 5000);
await expect(newDocumentButton).toBeVisible(); // await expect(newDocumentButton).toBeVisible();
await expect(newDocumentButton).toBeEnabled(); // await expect(newDocumentButton).toBeEnabled();
await newDocumentButton.click(); // await newDocumentButton.click();
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 = { // const newDocument = {
_id: newDocumentId, // _id: newDocumentId,
...setPartitionKeys(partitionKeys || []), // ...setPartitionKeys(partitionKeys || []),
}; // };
await documentsTab.resultsEditor.setText(JSON.stringify(newDocument)); // await documentsTab.resultsEditor.setText(JSON.stringify(newDocument));
const saveButton = await explorer.waitForCommandBarButton(CommandBarButton.Save, 5000); // const saveButton = await explorer.waitForCommandBarButton(CommandBarButton.Save, 5000);
await saveButton.click({ timeout: 5000 }); // await saveButton.click({ timeout: 5000 });
await expect(saveButton).toBeHidden({ timeout: 5000 }); // await expect(saveButton).toBeHidden({ timeout: 5000 });
}, 3); // }, 3);
await documentsTab.setFilter(`{_id: "${newDocumentId}"}`); // await documentsTab.setFilter(`{_id: "${newDocumentId}"}`);
await documentsTab.filterButton.click(); // await documentsTab.filterButton.click();
const newSpan = documentsTab.documentsListPane.getByText(newDocumentId, { exact: true }).nth(0); // const newSpan = documentsTab.documentsListPane.getByText(newDocumentId, { exact: true }).nth(0);
await newSpan.waitFor(); // await newSpan.waitFor();
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(CommandBarButton.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);
await deleteDialogButton.click(); // await deleteDialogButton.click();
const deletedSpan = documentsTab.documentsListPane.getByText(newDocumentId, { exact: true }).nth(0); // const deletedSpan = documentsTab.documentsListPane.getByText(newDocumentId, { exact: true }).nth(0);
await expect(deletedSpan).toHaveCount(0); // await expect(deletedSpan).toHaveCount(0);
}); // });
}); // });
} // }
}); // });
} // }
+104 -104
View File
@@ -1,133 +1,133 @@
import { expect, test } from "@playwright/test"; // import { expect, test } from "@playwright/test";
import { setupCORSBypass } from "../CORSBypass"; // import { setupCORSBypass } from "../CORSBypass";
import { CommandBarButton, DataExplorer, Editor, QueryTab, TestAccount } from "../fx"; // import { CommandBarButton, DataExplorer, Editor, QueryTab, TestAccount } from "../fx";
import { serializeMongoToJson } from "../testData"; // import { serializeMongoToJson } from "../testData";
const databaseId = "test-e2etests-mongo-pagination"; // const databaseId = "test-e2etests-mongo-pagination";
const collectionId = "test-coll-mongo-pagination"; // const collectionId = "test-coll-mongo-pagination";
let explorer: DataExplorer = null!; // let explorer: DataExplorer = null!;
test.setTimeout(5 * 60 * 1000); // test.setTimeout(5 * 60 * 1000);
test.describe("Test Mongo Pagination", () => { // test.describe("Test Mongo Pagination", () => {
let queryTab: QueryTab; // let queryTab: QueryTab;
let queryEditor: Editor; // let queryEditor: Editor;
test.beforeEach("Open query tab", async ({ page }) => { // test.beforeEach("Open query tab", async ({ page }) => {
await setupCORSBypass(page); // await setupCORSBypass(page);
explorer = await DataExplorer.open(page, TestAccount.MongoReadonly); // explorer = await DataExplorer.open(page, TestAccount.MongoReadonly);
const containerNode = await explorer.waitForContainerNode(databaseId, collectionId); // const containerNode = await explorer.waitForContainerNode(databaseId, collectionId);
await containerNode.expand(); // await containerNode.expand();
const containerMenuNode = await explorer.waitForContainerDocumentsNode(databaseId, collectionId); // const containerMenuNode = await explorer.waitForContainerDocumentsNode(databaseId, collectionId);
await containerMenuNode.openContextMenu(); // await containerMenuNode.openContextMenu();
await containerMenuNode.contextMenuItem("New Query").click(); // await containerMenuNode.contextMenuItem("New Query").click();
queryTab = explorer.queryTab("tab0"); // queryTab = explorer.queryTab("tab0");
queryEditor = queryTab.editor(); // queryEditor = queryTab.editor();
await queryEditor.locator.waitFor({ timeout: 30 * 1000 }); // await queryEditor.locator.waitFor({ timeout: 30 * 1000 });
await queryTab.executeCTA.waitFor(); // await queryTab.executeCTA.waitFor();
await explorer.frame.getByTestId("NotificationConsole/ExpandCollapseButton").click(); // await explorer.frame.getByTestId("NotificationConsole/ExpandCollapseButton").click();
await explorer.frame.getByTestId("NotificationConsole/Contents").waitFor(); // await explorer.frame.getByTestId("NotificationConsole/Contents").waitFor();
}); // });
test("should execute a query and load more results", async ({ page }) => { // test("should execute a query and load more results", async ({ page }) => {
test.skip(); // test.skip();
const query = "{}"; // const query = "{}";
await queryEditor.locator.click(); // await queryEditor.locator.click();
await queryEditor.setText(query); // await queryEditor.setText(query);
const executeQueryButton = explorer.commandBarButton(CommandBarButton.ExecuteQuery); // const executeQueryButton = explorer.commandBarButton(CommandBarButton.ExecuteQuery);
await executeQueryButton.click(); // await executeQueryButton.click();
// Wait for query execution to complete // // Wait for query execution to complete
await expect(queryTab.resultsView).toBeVisible({ timeout: 60000 }); // await expect(queryTab.resultsView).toBeVisible({ timeout: 60000 });
await expect(queryTab.resultsEditor.locator).toBeAttached({ timeout: 30000 }); // await expect(queryTab.resultsEditor.locator).toBeAttached({ timeout: 30000 });
// Get initial results // // Get initial results
const resultText = await queryTab.resultsEditor.text(); // const resultText = await queryTab.resultsEditor.text();
if (!resultText || resultText.trim() === "" || resultText.trim() === "[]") { // if (!resultText || resultText.trim() === "" || resultText.trim() === "[]") {
throw new Error("Query returned no results - the collection appears to be empty"); // throw new Error("Query returned no results - the collection appears to be empty");
} // }
const resultData = serializeMongoToJson(resultText); // const resultData = serializeMongoToJson(resultText);
if (resultData.length === 0) { // if (resultData.length === 0) {
throw new Error("Parsed results contain 0 documents - collection is empty"); // throw new Error("Parsed results contain 0 documents - collection is empty");
} // }
if (resultData.length < 100) { // if (resultData.length < 100) {
expect(resultData.length).toBeGreaterThan(0); // expect(resultData.length).toBeGreaterThan(0);
return; // return;
} // }
expect(resultData.length).toBe(100); // expect(resultData.length).toBe(100);
// Pagination test // // Pagination test
let totalPagesLoaded = 1; // let totalPagesLoaded = 1;
const maxLoadMoreAttempts = 10; // const maxLoadMoreAttempts = 10;
for (let loadMoreAttempts = 0; loadMoreAttempts < maxLoadMoreAttempts; loadMoreAttempts++) { // for (let loadMoreAttempts = 0; loadMoreAttempts < maxLoadMoreAttempts; loadMoreAttempts++) {
const loadMoreButton = queryTab.resultsView.getByText("Load more"); // const loadMoreButton = queryTab.resultsView.getByText("Load more");
try { // try {
await expect(loadMoreButton).toBeVisible({ timeout: 5000 }); // await expect(loadMoreButton).toBeVisible({ timeout: 5000 });
} catch { // } catch {
// Load more button not visible - pagination complete // // Load more button not visible - pagination complete
break; // break;
} // }
const beforeClickText = await queryTab.resultsEditor.text(); // const beforeClickText = await queryTab.resultsEditor.text();
const beforeClickHash = Buffer.from(beforeClickText || "") // const beforeClickHash = Buffer.from(beforeClickText || "")
.toString("base64") // .toString("base64")
.substring(0, 50); // .substring(0, 50);
await loadMoreButton.click(); // await loadMoreButton.click();
// Wait for content to update // // Wait for content to update
let editorContentChanged = false; // let editorContentChanged = false;
for (let waitAttempt = 1; waitAttempt <= 3; waitAttempt++) { // for (let waitAttempt = 1; waitAttempt <= 3; waitAttempt++) {
await page.waitForTimeout(2000); // await page.waitForTimeout(2000);
const currentEditorText = await queryTab.resultsEditor.text(); // const currentEditorText = await queryTab.resultsEditor.text();
const currentHash = Buffer.from(currentEditorText || "") // const currentHash = Buffer.from(currentEditorText || "")
.toString("base64") // .toString("base64")
.substring(0, 50); // .substring(0, 50);
if (currentHash !== beforeClickHash) { // if (currentHash !== beforeClickHash) {
editorContentChanged = true; // editorContentChanged = true;
break; // break;
} // }
} // }
if (editorContentChanged) { // if (editorContentChanged) {
totalPagesLoaded++; // totalPagesLoaded++;
} else { // } else {
// No content change detected, stop pagination // // No content change detected, stop pagination
break; // break;
} // }
await page.waitForTimeout(1000); // await page.waitForTimeout(1000);
} // }
// Final verification // // Final verification
const finalIndicator = queryTab.resultsView.locator("text=/\\d+ - \\d+/"); // const finalIndicator = queryTab.resultsView.locator("text=/\\d+ - \\d+/");
const finalIndicatorText = await finalIndicator.textContent(); // const finalIndicatorText = await finalIndicator.textContent();
if (finalIndicatorText) { // if (finalIndicatorText) {
const match = finalIndicatorText.match(/(\d+) - (\d+)/); // const match = finalIndicatorText.match(/(\d+) - (\d+)/);
if (match) { // if (match) {
const totalDocuments = parseInt(match[2]); // const totalDocuments = parseInt(match[2]);
expect(totalDocuments).toBe(405); // expect(totalDocuments).toBe(405);
expect(totalPagesLoaded).toBe(5); // expect(totalPagesLoaded).toBe(5);
} else { // } else {
throw new Error(`Invalid results indicator format: ${finalIndicatorText}`); // throw new Error(`Invalid results indicator format: ${finalIndicatorText}`);
} // }
} else { // } else {
expect(totalPagesLoaded).toBe(5); // expect(totalPagesLoaded).toBe(5);
} // }
}); // });
}); // });
+215 -215
View File
@@ -1,265 +1,265 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ // /* eslint-disable @typescript-eslint/no-explicit-any */
import { expect, Frame, Locator, Page, test } from "@playwright/test"; // import { expect, Frame, Locator, Page, test } from "@playwright/test";
import { truncateName } from "../../../src/Explorer/ContainerCopy/CopyJobUtils"; // import { truncateName } from "../../../src/Explorer/ContainerCopy/CopyJobUtils";
import { // import {
ContainerCopy, // ContainerCopy,
getAccountName, // getAccountName,
getDropdownItemByNameOrPosition, // getDropdownItemByNameOrPosition,
interceptAndInspectApiRequest, // interceptAndInspectApiRequest,
TestAccount, // TestAccount,
waitForApiResponse, // waitForApiResponse,
} from "../../fx"; // } from "../../fx";
import { createMultipleTestContainers, TestContainerContext } from "../../testData"; // import { createMultipleTestContainers, TestContainerContext } from "../../testData";
test.describe("Container Copy - Offline Migration", () => { // test.describe("Container Copy - Offline Migration", () => {
let contexts: TestContainerContext[]; // let contexts: TestContainerContext[];
let page: Page; // let page: Page;
let wrapper: Locator; // let wrapper: Locator;
let panel: Locator; // let panel: Locator;
let frame: Frame; // let frame: Frame;
let expectedJobName: string; // let expectedJobName: string;
let sourceAccountName: string; // let sourceAccountName: string;
let expectedSubscriptionName: string; // let expectedSubscriptionName: string;
let expectedCopyJobNameInitial: string; // let expectedCopyJobNameInitial: string;
test.beforeEach("Setup for offline migration test", async ({ browser }) => { // test.beforeEach("Setup for offline migration test", async ({ browser }) => {
contexts = await createMultipleTestContainers({ accountType: TestAccount.SQLContainerCopyOnly, containerCount: 2 }); // contexts = await createMultipleTestContainers({ accountType: TestAccount.SQLContainerCopyOnly, containerCount: 2 });
page = await browser.newPage(); // page = await browser.newPage();
({ wrapper, frame } = await ContainerCopy.open(page, TestAccount.SQLContainerCopyOnly)); // ({ wrapper, frame } = await ContainerCopy.open(page, TestAccount.SQLContainerCopyOnly));
expectedJobName = `offline_test_job_${Date.now()}`; // expectedJobName = `offline_test_job_${Date.now()}`;
sourceAccountName = getAccountName(TestAccount.SQLContainerCopyOnly); // sourceAccountName = getAccountName(TestAccount.SQLContainerCopyOnly);
}); // });
test.afterEach("Cleanup after offline migration test", async () => { // test.afterEach("Cleanup after offline migration test", async () => {
await page.unroute(/.*/, (route) => route.continue()); // await page.unroute(/.*/, (route) => route.continue());
await page.close(); // await page.close();
await Promise.all(contexts.map((context) => context?.dispose())); // await Promise.all(contexts.map((context) => context?.dispose()));
}); // });
test("Successfully create and manage offline migration copy job", async () => { // test("Successfully create and manage offline migration copy job", async () => {
test.skip(); // test.skip();
expect(wrapper).not.toBeNull(); // expect(wrapper).not.toBeNull();
await wrapper.locator(".commandBarContainer").waitFor({ state: "visible" }); // await wrapper.locator(".commandBarContainer").waitFor({ state: "visible" });
// Open Create Copy Job panel // // Open Create Copy Job panel
const createCopyJobButton = wrapper.getByTestId("CommandBar/Button:Create Copy Job"); // const createCopyJobButton = wrapper.getByTestId("CommandBar/Button:Create Copy Job");
await expect(createCopyJobButton).toBeVisible(); // await expect(createCopyJobButton).toBeVisible();
await createCopyJobButton.click(); // await createCopyJobButton.click();
panel = frame.getByTestId("Panel:Create copy job"); // panel = frame.getByTestId("Panel:Create copy job");
await expect(panel).toBeVisible(); // await expect(panel).toBeVisible();
// Reduced wait time for better performance // // Reduced wait time for better performance
await page.waitForTimeout(2000); // await page.waitForTimeout(2000);
// Setup subscription and account // // Setup subscription and account
const subscriptionDropdown = panel.getByTestId("subscription-dropdown"); // const subscriptionDropdown = panel.getByTestId("subscription-dropdown");
const expectedAccountName = sourceAccountName; // const expectedAccountName = sourceAccountName;
expectedSubscriptionName = await subscriptionDropdown.locator("span.ms-Dropdown-title").innerText(); // expectedSubscriptionName = await subscriptionDropdown.locator("span.ms-Dropdown-title").innerText();
await subscriptionDropdown.click(); // await subscriptionDropdown.click();
const subscriptionItem = await getDropdownItemByNameOrPosition( // const subscriptionItem = await getDropdownItemByNameOrPosition(
frame, // frame,
{ name: expectedSubscriptionName }, // { name: expectedSubscriptionName },
{ ariaLabel: "Subscription" }, // { ariaLabel: "Subscription" },
); // );
await subscriptionItem.click(); // await subscriptionItem.click();
// Select account // // Select account
const accountDropdown = panel.getByTestId("account-dropdown"); // const accountDropdown = panel.getByTestId("account-dropdown");
await expect(accountDropdown).toHaveText(new RegExp(expectedAccountName)); // await expect(accountDropdown).toHaveText(new RegExp(expectedAccountName));
await accountDropdown.click(); // await accountDropdown.click();
const accountItem = await getDropdownItemByNameOrPosition( // const accountItem = await getDropdownItemByNameOrPosition(
frame, // frame,
{ name: expectedAccountName }, // { name: expectedAccountName },
{ ariaLabel: "Account" }, // { ariaLabel: "Account" },
); // );
await accountItem.click(); // await accountItem.click();
// Test offline migration mode toggle functionality // // Test offline migration mode toggle functionality
const migrationTypeContainer = panel.getByTestId("migration-type"); // const migrationTypeContainer = panel.getByTestId("migration-type");
// First test online mode (should show permissions screen) // // First test online mode (should show permissions screen)
const onlineCopyRadioButton = migrationTypeContainer.getByRole("radio", { name: /Online mode/i }); // const onlineCopyRadioButton = migrationTypeContainer.getByRole("radio", { name: /Online mode/i });
await onlineCopyRadioButton.click({ force: true }); // await onlineCopyRadioButton.click({ force: true });
await expect(migrationTypeContainer.getByTestId("migration-type-description-online")).toBeVisible(); // await expect(migrationTypeContainer.getByTestId("migration-type-description-online")).toBeVisible();
await panel.getByRole("button", { name: "Next" }).click(); // await panel.getByRole("button", { name: "Next" }).click();
await expect(panel.getByTestId("Panel:AssignPermissionsContainer")).toBeVisible(); // await expect(panel.getByTestId("Panel:AssignPermissionsContainer")).toBeVisible();
await expect(panel.getByText("Online container copy", { exact: true })).toBeVisible(); // await expect(panel.getByText("Online container copy", { exact: true })).toBeVisible();
// Go back and switch to offline mode // // Go back and switch to offline mode
await panel.getByRole("button", { name: "Previous" }).click(); // await panel.getByRole("button", { name: "Previous" }).click();
const offlineCopyRadioButton = migrationTypeContainer.getByRole("radio", { name: /Offline mode/i }); // const offlineCopyRadioButton = migrationTypeContainer.getByRole("radio", { name: /Offline mode/i });
await offlineCopyRadioButton.click({ force: true }); // await offlineCopyRadioButton.click({ force: true });
await expect(migrationTypeContainer.getByTestId("migration-type-description-offline")).toBeVisible(); // await expect(migrationTypeContainer.getByTestId("migration-type-description-offline")).toBeVisible();
await panel.getByRole("button", { name: "Next" }).click(); // await panel.getByRole("button", { name: "Next" }).click();
// Verify we skip permissions screen in offline mode // // Verify we skip permissions screen in offline mode
await expect(panel.getByTestId("Panel:SelectSourceAndTargetContainers")).toBeVisible(); // await expect(panel.getByTestId("Panel:SelectSourceAndTargetContainers")).toBeVisible();
await expect(panel.getByTestId("Panel:AssignPermissionsContainer")).not.toBeVisible(); // await expect(panel.getByTestId("Panel:AssignPermissionsContainer")).not.toBeVisible();
// Test source and target container selection with validation // // Test source and target container selection with validation
const sourceContainerDropdown = panel.getByTestId("source-containerDropdown"); // const sourceContainerDropdown = panel.getByTestId("source-containerDropdown");
expect(sourceContainerDropdown).toBeVisible(); // expect(sourceContainerDropdown).toBeVisible();
await expect(sourceContainerDropdown).toHaveClass(/(^|\s)is-disabled(\s|$)/); // await expect(sourceContainerDropdown).toHaveClass(/(^|\s)is-disabled(\s|$)/);
// Select source database first (containers are disabled until database is selected) // // Select source database first (containers are disabled until database is selected)
const sourceDatabaseDropdown = panel.getByTestId("source-databaseDropdown"); // const sourceDatabaseDropdown = panel.getByTestId("source-databaseDropdown");
await sourceDatabaseDropdown.click(); // await sourceDatabaseDropdown.click();
const sourceDbDropdownItem = await getDropdownItemByNameOrPosition( // const sourceDbDropdownItem = await getDropdownItemByNameOrPosition(
frame, // frame,
{ position: 0 }, // { position: 0 },
{ ariaLabel: "Database" }, // { ariaLabel: "Database" },
); // );
await sourceDbDropdownItem.click(); // await sourceDbDropdownItem.click();
// Now container dropdown should be enabled // // Now container dropdown should be enabled
await expect(sourceContainerDropdown).not.toHaveClass(/(^|\s)is-disabled(\s|$)/); // await expect(sourceContainerDropdown).not.toHaveClass(/(^|\s)is-disabled(\s|$)/);
await sourceContainerDropdown.click(); // await sourceContainerDropdown.click();
const sourceContainerDropdownItem = await getDropdownItemByNameOrPosition( // const sourceContainerDropdownItem = await getDropdownItemByNameOrPosition(
frame, // frame,
{ position: 0 }, // { position: 0 },
{ ariaLabel: "Container" }, // { ariaLabel: "Container" },
); // );
await sourceContainerDropdownItem.click(); // await sourceContainerDropdownItem.click();
// Test target container selection // // Test target container selection
const targetContainerDropdown = panel.getByTestId("target-containerDropdown"); // const targetContainerDropdown = panel.getByTestId("target-containerDropdown");
expect(targetContainerDropdown).toBeVisible(); // expect(targetContainerDropdown).toBeVisible();
await expect(targetContainerDropdown).toHaveClass(/(^|\s)is-disabled(\s|$)/); // await expect(targetContainerDropdown).toHaveClass(/(^|\s)is-disabled(\s|$)/);
const targetDatabaseDropdown = panel.getByTestId("target-databaseDropdown"); // const targetDatabaseDropdown = panel.getByTestId("target-databaseDropdown");
await targetDatabaseDropdown.click(); // await targetDatabaseDropdown.click();
const targetDbDropdownItem = await getDropdownItemByNameOrPosition( // const targetDbDropdownItem = await getDropdownItemByNameOrPosition(
frame, // frame,
{ position: 0 }, // { position: 0 },
{ ariaLabel: "Database" }, // { ariaLabel: "Database" },
); // );
await targetDbDropdownItem.click(); // await targetDbDropdownItem.click();
await expect(targetContainerDropdown).not.toHaveClass(/(^|\s)is-disabled(\s|$)/); // await expect(targetContainerDropdown).not.toHaveClass(/(^|\s)is-disabled(\s|$)/);
await targetContainerDropdown.click(); // await targetContainerDropdown.click();
// First try selecting the same container (should show error) // // First try selecting the same container (should show error)
const targetContainerDropdownItem1 = await getDropdownItemByNameOrPosition( // const targetContainerDropdownItem1 = await getDropdownItemByNameOrPosition(
frame, // frame,
{ position: 0 }, // { position: 0 },
{ ariaLabel: "Container" }, // { ariaLabel: "Container" },
); // );
await targetContainerDropdownItem1.click(); // await targetContainerDropdownItem1.click();
await panel.getByRole("button", { name: "Next" }).click(); // await panel.getByRole("button", { name: "Next" }).click();
// Verify validation error for same source and target containers // // Verify validation error for same source and target containers
const errorContainer = panel.getByTestId("Panel:ErrorContainer"); // const errorContainer = panel.getByTestId("Panel:ErrorContainer");
await expect(errorContainer).toBeVisible(); // await expect(errorContainer).toBeVisible();
await expect(errorContainer).toHaveText(/Source and destination containers cannot be the same/i); // await expect(errorContainer).toHaveText(/Source and destination containers cannot be the same/i);
// Select different target container // // Select different target container
await targetContainerDropdown.click(); // await targetContainerDropdown.click();
const targetContainerDropdownItem2 = await getDropdownItemByNameOrPosition( // const targetContainerDropdownItem2 = await getDropdownItemByNameOrPosition(
frame, // frame,
{ position: 1 }, // { position: 1 },
{ ariaLabel: "Container" }, // { ariaLabel: "Container" },
); // );
await targetContainerDropdownItem2.click(); // await targetContainerDropdownItem2.click();
// Generate expected job name based on selections // // Generate expected job name based on selections
const selectedSourceDatabase = await sourceDatabaseDropdown.innerText(); // const selectedSourceDatabase = await sourceDatabaseDropdown.innerText();
const selectedSourceContainer = await sourceContainerDropdown.innerText(); // const selectedSourceContainer = await sourceContainerDropdown.innerText();
const selectedTargetDatabase = await targetDatabaseDropdown.innerText(); // const selectedTargetDatabase = await targetDatabaseDropdown.innerText();
const selectedTargetContainer = await targetContainerDropdown.innerText(); // const selectedTargetContainer = await targetContainerDropdown.innerText();
expectedCopyJobNameInitial = `${truncateName(selectedSourceDatabase)}.${truncateName( // expectedCopyJobNameInitial = `${truncateName(selectedSourceDatabase)}.${truncateName(
selectedSourceContainer, // selectedSourceContainer,
)}_${truncateName(selectedTargetDatabase)}.${truncateName(selectedTargetContainer)}`; // )}_${truncateName(selectedTargetDatabase)}.${truncateName(selectedTargetContainer)}`;
await panel.getByRole("button", { name: "Next" }).click(); // await panel.getByRole("button", { name: "Next" }).click();
// Error should disappear and preview should be visible // // Error should disappear and preview should be visible
await expect(errorContainer).not.toBeVisible(); // await expect(errorContainer).not.toBeVisible();
await expect(panel.getByTestId("Panel:PreviewCopyJob")).toBeVisible(); // await expect(panel.getByTestId("Panel:PreviewCopyJob")).toBeVisible();
// Verify job preview details // // Verify job preview details
const previewContainer = panel.getByTestId("Panel:PreviewCopyJob"); // const previewContainer = panel.getByTestId("Panel:PreviewCopyJob");
await expect(previewContainer).toBeVisible(); // await expect(previewContainer).toBeVisible();
await expect(previewContainer.getByTestId("destination-subscription-name")).toHaveText(expectedSubscriptionName); // await expect(previewContainer.getByTestId("destination-subscription-name")).toHaveText(expectedSubscriptionName);
await expect(previewContainer.getByTestId("destination-account-name")).toHaveText(expectedAccountName); // await expect(previewContainer.getByTestId("destination-account-name")).toHaveText(expectedAccountName);
const jobNameInput = previewContainer.getByTestId("job-name-textfield"); // const jobNameInput = previewContainer.getByTestId("job-name-textfield");
await expect(jobNameInput).toHaveValue(new RegExp(expectedCopyJobNameInitial)); // await expect(jobNameInput).toHaveValue(new RegExp(expectedCopyJobNameInitial));
const primaryBtn = panel.getByRole("button", { name: "Copy", exact: true }); // const primaryBtn = panel.getByRole("button", { name: "Copy", exact: true });
await expect(primaryBtn).not.toHaveClass(/(^|\s)is-disabled(\s|$)/); // await expect(primaryBtn).not.toHaveClass(/(^|\s)is-disabled(\s|$)/);
// Test invalid job name validation (spaces not allowed) // // Test invalid job name validation (spaces not allowed)
await jobNameInput.fill("test job name"); // await jobNameInput.fill("test job name");
await expect(primaryBtn).toHaveClass(/(^|\s)is-disabled(\s|$)/); // await expect(primaryBtn).toHaveClass(/(^|\s)is-disabled(\s|$)/);
// Test duplicate job name error handling // // Test duplicate job name error handling
const duplicateJobName = "test-job-name-1"; // const duplicateJobName = "test-job-name-1";
await jobNameInput.fill(duplicateJobName); // await jobNameInput.fill(duplicateJobName);
const copyButton = panel.getByRole("button", { name: "Copy", exact: true }); // const copyButton = panel.getByRole("button", { name: "Copy", exact: true });
const expectedErrorMessage = `Duplicate job name '${duplicateJobName}'`; // const expectedErrorMessage = `Duplicate job name '${duplicateJobName}'`;
await interceptAndInspectApiRequest( // await interceptAndInspectApiRequest(
page, // page,
`${expectedAccountName}/dataTransferJobs/${duplicateJobName}`, // `${expectedAccountName}/dataTransferJobs/${duplicateJobName}`,
"PUT", // "PUT",
new Error(expectedErrorMessage), // new Error(expectedErrorMessage),
(url?: string) => url?.includes(duplicateJobName) ?? false, // (url?: string) => url?.includes(duplicateJobName) ?? false,
); // );
let errorThrown = false; // let errorThrown = false;
try { // try {
await copyButton.click(); // await copyButton.click();
await page.waitForTimeout(2000); // await page.waitForTimeout(2000);
} catch (error: any) { // } catch (error: any) {
errorThrown = true; // errorThrown = true;
expect(error.message).toContain("not allowed"); // expect(error.message).toContain("not allowed");
} // }
if (!errorThrown) { // if (!errorThrown) {
const errorContainer = panel.getByTestId("Panel:ErrorContainer"); // const errorContainer = panel.getByTestId("Panel:ErrorContainer");
await expect(errorContainer).toBeVisible(); // await expect(errorContainer).toBeVisible();
await expect(errorContainer).toHaveText(new RegExp(expectedErrorMessage, "i")); // await expect(errorContainer).toHaveText(new RegExp(expectedErrorMessage, "i"));
} // }
await expect(panel).toBeVisible(); // await expect(panel).toBeVisible();
// Test successful job creation with valid job name // // Test successful job creation with valid job name
const validJobName = expectedJobName; // const validJobName = expectedJobName;
const copyJobCreationPromise = waitForApiResponse( // const copyJobCreationPromise = waitForApiResponse(
page, // page,
`${expectedAccountName}/dataTransferJobs/${validJobName}`, // `${expectedAccountName}/dataTransferJobs/${validJobName}`,
"PUT", // "PUT",
); // );
await jobNameInput.fill(validJobName); // await jobNameInput.fill(validJobName);
await expect(copyButton).not.toHaveClass(/(^|\s)is-disabled(\s|$)/); // await expect(copyButton).not.toHaveClass(/(^|\s)is-disabled(\s|$)/);
await copyButton.click(); // await copyButton.click();
const response = await copyJobCreationPromise; // const response = await copyJobCreationPromise;
expect(response.ok()).toBe(true); // expect(response.ok()).toBe(true);
// Verify panel closes and job appears in the list // // Verify panel closes and job appears in the list
await expect(panel).not.toBeVisible(); // await expect(panel).not.toBeVisible();
const filterTextField = wrapper.getByTestId("CopyJobsList/FilterTextField"); // const filterTextField = wrapper.getByTestId("CopyJobsList/FilterTextField");
await filterTextField.waitFor({ state: "visible" }); // await filterTextField.waitFor({ state: "visible" });
await filterTextField.fill(validJobName); // await filterTextField.fill(validJobName);
const jobsListContainer = wrapper.locator(".CopyJobListContainer .ms-DetailsList-contentWrapper .ms-List-page"); // const jobsListContainer = wrapper.locator(".CopyJobListContainer .ms-DetailsList-contentWrapper .ms-List-page");
await jobsListContainer.waitFor({ state: "visible" }); // await jobsListContainer.waitFor({ state: "visible" });
const jobItem = jobsListContainer.getByText(validJobName); // const jobItem = jobsListContainer.getByText(validJobName);
await jobItem.waitFor({ state: "visible" }); // await jobItem.waitFor({ state: "visible" });
await expect(jobItem).toBeVisible(); // await expect(jobItem).toBeVisible();
}); // });
}); // });
+155 -155
View File
@@ -1,192 +1,192 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ // /* eslint-disable @typescript-eslint/no-explicit-any */
import { expect, Frame, Locator, Page, test } from "@playwright/test"; // import { expect, Frame, Locator, Page, test } from "@playwright/test";
import { // import {
ContainerCopy, // ContainerCopy,
getAccountName, // getAccountName,
getDropdownItemByNameOrPosition, // getDropdownItemByNameOrPosition,
TestAccount, // TestAccount,
waitForApiResponse, // waitForApiResponse,
} from "../../fx"; // } from "../../fx";
import { createMultipleTestContainers, TestContainerContext } from "../../testData"; // import { createMultipleTestContainers, TestContainerContext } from "../../testData";
test.describe("Container Copy - Online Migration", () => { // test.describe("Container Copy - Online Migration", () => {
let contexts: TestContainerContext[]; // let contexts: TestContainerContext[];
let page: Page; // let page: Page;
let wrapper: Locator; // let wrapper: Locator;
let panel: Locator; // let panel: Locator;
let frame: Frame; // let frame: Frame;
let sourceAccountName: string; // let sourceAccountName: string;
test.beforeEach("Setup for online migration test", async ({ browser }) => { // test.beforeEach("Setup for online migration test", async ({ browser }) => {
contexts = await createMultipleTestContainers({ accountType: TestAccount.SQLContainerCopyOnly, containerCount: 2 }); // contexts = await createMultipleTestContainers({ accountType: TestAccount.SQLContainerCopyOnly, containerCount: 2 });
page = await browser.newPage(); // page = await browser.newPage();
({ wrapper, frame } = await ContainerCopy.open(page, TestAccount.SQLContainerCopyOnly)); // ({ wrapper, frame } = await ContainerCopy.open(page, TestAccount.SQLContainerCopyOnly));
sourceAccountName = getAccountName(TestAccount.SQLContainerCopyOnly); // sourceAccountName = getAccountName(TestAccount.SQLContainerCopyOnly);
}); // });
test.afterEach("Cleanup after online migration test", async () => { // test.afterEach("Cleanup after online migration test", async () => {
await page.unroute(/.*/, (route) => route.continue()); // await page.unroute(/.*/, (route) => route.continue());
await page.close(); // await page.close();
await Promise.all(contexts.map((context) => context?.dispose())); // await Promise.all(contexts.map((context) => context?.dispose()));
}); // });
test("Successfully create and manage online migration copy job", async () => { // test("Successfully create and manage online migration copy job", async () => {
test.skip(); // test.skip();
expect(wrapper).not.toBeNull(); // expect(wrapper).not.toBeNull();
await wrapper.locator(".commandBarContainer").waitFor({ state: "visible" }); // await wrapper.locator(".commandBarContainer").waitFor({ state: "visible" });
// Open Create Copy Job panel // // Open Create Copy Job panel
const createCopyJobButton = wrapper.getByTestId("CommandBar/Button:Create Copy Job"); // const createCopyJobButton = wrapper.getByTestId("CommandBar/Button:Create Copy Job");
await expect(createCopyJobButton).toBeVisible(); // await expect(createCopyJobButton).toBeVisible();
await createCopyJobButton.click(); // await createCopyJobButton.click();
panel = frame.getByTestId("Panel:Create copy job"); // panel = frame.getByTestId("Panel:Create copy job");
await expect(panel).toBeVisible(); // await expect(panel).toBeVisible();
// Reduced wait time for better performance // // Reduced wait time for better performance
await page.waitForTimeout(1000); // await page.waitForTimeout(1000);
// Enable online migration mode // // Enable online migration mode
const migrationTypeContainer = panel.getByTestId("migration-type"); // const migrationTypeContainer = panel.getByTestId("migration-type");
const onlineCopyRadioButton = migrationTypeContainer.getByRole("radio", { name: /Online mode/i }); // const onlineCopyRadioButton = migrationTypeContainer.getByRole("radio", { name: /Online mode/i });
await onlineCopyRadioButton.click({ force: true }); // await onlineCopyRadioButton.click({ force: true });
await expect(migrationTypeContainer.getByTestId("migration-type-description-online")).toBeVisible(); // await expect(migrationTypeContainer.getByTestId("migration-type-description-online")).toBeVisible();
await panel.getByRole("button", { name: "Next" }).click(); // await panel.getByRole("button", { name: "Next" }).click();
// Verify permissions screen is shown for online migration // // Verify permissions screen is shown for online migration
const permissionScreen = panel.getByTestId("Panel:AssignPermissionsContainer"); // const permissionScreen = panel.getByTestId("Panel:AssignPermissionsContainer");
await expect(permissionScreen).toBeVisible(); // await expect(permissionScreen).toBeVisible();
await expect(permissionScreen.getByText("Online container copy", { exact: true })).toBeVisible(); // await expect(permissionScreen.getByText("Online container copy", { exact: true })).toBeVisible();
// Skip permissions setup and proceed to container selection // // Skip permissions setup and proceed to container selection
await panel.getByRole("button", { name: "Next" }).click(); // await panel.getByRole("button", { name: "Next" }).click();
// Configure source and target containers for online migration // // Configure source and target containers for online migration
const sourceDatabaseDropdown = panel.getByTestId("source-databaseDropdown"); // const sourceDatabaseDropdown = panel.getByTestId("source-databaseDropdown");
await sourceDatabaseDropdown.click(); // await sourceDatabaseDropdown.click();
const sourceDbDropdownItem = await getDropdownItemByNameOrPosition( // const sourceDbDropdownItem = await getDropdownItemByNameOrPosition(
frame, // frame,
{ position: 0 }, // { position: 0 },
{ ariaLabel: "Database" }, // { ariaLabel: "Database" },
); // );
await sourceDbDropdownItem.click(); // await sourceDbDropdownItem.click();
const sourceContainerDropdown = panel.getByTestId("source-containerDropdown"); // const sourceContainerDropdown = panel.getByTestId("source-containerDropdown");
await sourceContainerDropdown.click(); // await sourceContainerDropdown.click();
const sourceContainerDropdownItem = await getDropdownItemByNameOrPosition( // const sourceContainerDropdownItem = await getDropdownItemByNameOrPosition(
frame, // frame,
{ position: 0 }, // { position: 0 },
{ ariaLabel: "Container" }, // { ariaLabel: "Container" },
); // );
await sourceContainerDropdownItem.click(); // await sourceContainerDropdownItem.click();
const targetDatabaseDropdown = panel.getByTestId("target-databaseDropdown"); // const targetDatabaseDropdown = panel.getByTestId("target-databaseDropdown");
await targetDatabaseDropdown.click(); // await targetDatabaseDropdown.click();
const targetDbDropdownItem = await getDropdownItemByNameOrPosition( // const targetDbDropdownItem = await getDropdownItemByNameOrPosition(
frame, // frame,
{ position: 0 }, // { position: 0 },
{ ariaLabel: "Database" }, // { ariaLabel: "Database" },
); // );
await targetDbDropdownItem.click(); // await targetDbDropdownItem.click();
const targetContainerDropdown = panel.getByTestId("target-containerDropdown"); // const targetContainerDropdown = panel.getByTestId("target-containerDropdown");
await targetContainerDropdown.click(); // await targetContainerDropdown.click();
const targetContainerDropdownItem = await getDropdownItemByNameOrPosition( // const targetContainerDropdownItem = await getDropdownItemByNameOrPosition(
frame, // frame,
{ position: 1 }, // { position: 1 },
{ ariaLabel: "Container" }, // { ariaLabel: "Container" },
); // );
await targetContainerDropdownItem.click(); // await targetContainerDropdownItem.click();
await panel.getByRole("button", { name: "Next" }).click(); // await panel.getByRole("button", { name: "Next" }).click();
// Verify job preview and create the online migration job // // Verify job preview and create the online migration job
const previewContainer = panel.getByTestId("Panel:PreviewCopyJob"); // const previewContainer = panel.getByTestId("Panel:PreviewCopyJob");
await expect(previewContainer.getByTestId("destination-account-name")).toHaveText(sourceAccountName); // await expect(previewContainer.getByTestId("destination-account-name")).toHaveText(sourceAccountName);
const jobNameInput = previewContainer.getByTestId("job-name-textfield"); // const jobNameInput = previewContainer.getByTestId("job-name-textfield");
const onlineMigrationJobName = await jobNameInput.inputValue(); // const onlineMigrationJobName = await jobNameInput.inputValue();
const copyButton = panel.getByRole("button", { name: "Copy", exact: true }); // const copyButton = panel.getByRole("button", { name: "Copy", exact: true });
const copyJobCreationPromise = waitForApiResponse( // const copyJobCreationPromise = waitForApiResponse(
page, // page,
`${sourceAccountName}/dataTransferJobs/${onlineMigrationJobName}`, // `${sourceAccountName}/dataTransferJobs/${onlineMigrationJobName}`,
"PUT", // "PUT",
); // );
await copyButton.click(); // await copyButton.click();
await page.waitForTimeout(1000); // Reduced wait time // await page.waitForTimeout(1000); // Reduced wait time
const response = await copyJobCreationPromise; // const response = await copyJobCreationPromise;
expect(response.ok()).toBe(true); // expect(response.ok()).toBe(true);
// Verify panel closes and job appears in the list // // Verify panel closes and job appears in the list
await expect(panel).not.toBeVisible(); // await expect(panel).not.toBeVisible();
const filterTextField = wrapper.getByTestId("CopyJobsList/FilterTextField"); // const filterTextField = wrapper.getByTestId("CopyJobsList/FilterTextField");
await filterTextField.waitFor({ state: "visible" }); // await filterTextField.waitFor({ state: "visible" });
await filterTextField.fill(onlineMigrationJobName); // await filterTextField.fill(onlineMigrationJobName);
const jobsListContainer = wrapper.locator(".CopyJobListContainer .ms-DetailsList-contentWrapper .ms-List-page"); // const jobsListContainer = wrapper.locator(".CopyJobListContainer .ms-DetailsList-contentWrapper .ms-List-page");
await jobsListContainer.waitFor({ state: "visible" }); // await jobsListContainer.waitFor({ state: "visible" });
let jobRow, statusCell, actionMenuButton; // let jobRow, statusCell, actionMenuButton;
jobRow = jobsListContainer.locator(".ms-DetailsRow", { hasText: onlineMigrationJobName }); // jobRow = jobsListContainer.locator(".ms-DetailsRow", { hasText: onlineMigrationJobName });
statusCell = jobRow.locator("[data-automationid='DetailsRowCell'][data-automation-key='CopyJobStatus']"); // statusCell = jobRow.locator("[data-automationid='DetailsRowCell'][data-automation-key='CopyJobStatus']");
await jobRow.waitFor({ state: "visible" }); // await jobRow.waitFor({ state: "visible" });
// Verify job status changes to queued state // // Verify job status changes to queued state
await expect(statusCell).toContainText(/running|queued|pending/i); // await expect(statusCell).toContainText(/running|queued|pending/i);
// Test job lifecycle management through action menu // // Test job lifecycle management through action menu
actionMenuButton = wrapper.getByTestId(`CopyJobActionMenu/Button:${onlineMigrationJobName}`); // actionMenuButton = wrapper.getByTestId(`CopyJobActionMenu/Button:${onlineMigrationJobName}`);
await actionMenuButton.click(); // await actionMenuButton.click();
// Test pause functionality // // Test pause functionality
const pauseAction = frame.locator(".ms-ContextualMenu-list button:has-text('Pause')"); // const pauseAction = frame.locator(".ms-ContextualMenu-list button:has-text('Pause')");
await pauseAction.click(); // await pauseAction.click();
const pauseResponse = await waitForApiResponse( // const pauseResponse = await waitForApiResponse(
page, // page,
`${sourceAccountName}/dataTransferJobs/${onlineMigrationJobName}/pause`, // `${sourceAccountName}/dataTransferJobs/${onlineMigrationJobName}/pause`,
"POST", // "POST",
); // );
expect(pauseResponse.ok()).toBe(true); // expect(pauseResponse.ok()).toBe(true);
// Verify job status changes to paused // // Verify job status changes to paused
jobRow = jobsListContainer.locator(".ms-DetailsRow", { hasText: onlineMigrationJobName }); // jobRow = jobsListContainer.locator(".ms-DetailsRow", { hasText: onlineMigrationJobName });
await jobRow.waitFor({ state: "visible", timeout: 5000 }); // await jobRow.waitFor({ state: "visible", timeout: 5000 });
statusCell = jobRow.locator("[data-automationid='DetailsRowCell'][data-automation-key='CopyJobStatus']"); // statusCell = jobRow.locator("[data-automationid='DetailsRowCell'][data-automation-key='CopyJobStatus']");
await expect(statusCell).toContainText(/paused/i, { timeout: 5000 }); // await expect(statusCell).toContainText(/paused/i, { timeout: 5000 });
await page.waitForTimeout(1000); // await page.waitForTimeout(1000);
// Test cancel job functionality // // Test cancel job functionality
actionMenuButton = wrapper.getByTestId(`CopyJobActionMenu/Button:${onlineMigrationJobName}`); // actionMenuButton = wrapper.getByTestId(`CopyJobActionMenu/Button:${onlineMigrationJobName}`);
await actionMenuButton.click(); // await actionMenuButton.click();
await frame.locator(".ms-ContextualMenu-list button:has-text('Cancel')").click(); // await frame.locator(".ms-ContextualMenu-list button:has-text('Cancel')").click();
// Verify cancellation confirmation dialog // // Verify cancellation confirmation dialog
await expect(frame.locator(".ms-Dialog-main")).toBeVisible({ timeout: 2000 }); // await expect(frame.locator(".ms-Dialog-main")).toBeVisible({ timeout: 2000 });
await expect(frame.locator(".ms-Dialog-main")).toContainText(onlineMigrationJobName); // await expect(frame.locator(".ms-Dialog-main")).toContainText(onlineMigrationJobName);
const cancelDialogButton = frame.locator(".ms-Dialog-main").getByTestId("DialogButton:Cancel"); // const cancelDialogButton = frame.locator(".ms-Dialog-main").getByTestId("DialogButton:Cancel");
await expect(cancelDialogButton).toBeVisible(); // await expect(cancelDialogButton).toBeVisible();
await cancelDialogButton.click(); // await cancelDialogButton.click();
await expect(frame.locator(".ms-Dialog-main")).not.toBeVisible(); // await expect(frame.locator(".ms-Dialog-main")).not.toBeVisible();
actionMenuButton = wrapper.getByTestId(`CopyJobActionMenu/Button:${onlineMigrationJobName}`); // actionMenuButton = wrapper.getByTestId(`CopyJobActionMenu/Button:${onlineMigrationJobName}`);
await actionMenuButton.click(); // await actionMenuButton.click();
await frame.locator(".ms-ContextualMenu-list button:has-text('Cancel')").click(); // await frame.locator(".ms-ContextualMenu-list button:has-text('Cancel')").click();
const confirmDialogButton = frame.locator(".ms-Dialog-main").getByTestId("DialogButton:Confirm"); // const confirmDialogButton = frame.locator(".ms-Dialog-main").getByTestId("DialogButton:Confirm");
await expect(confirmDialogButton).toBeVisible(); // await expect(confirmDialogButton).toBeVisible();
await confirmDialogButton.click(); // await confirmDialogButton.click();
// Verify final job status is cancelled // // Verify final job status is cancelled
jobRow = jobsListContainer.locator(".ms-DetailsRow", { hasText: onlineMigrationJobName }); // jobRow = jobsListContainer.locator(".ms-DetailsRow", { hasText: onlineMigrationJobName });
statusCell = jobRow.locator("[data-automationid='DetailsRowCell'][data-automation-key='CopyJobStatus']"); // statusCell = jobRow.locator("[data-automationid='DetailsRowCell'][data-automation-key='CopyJobStatus']");
await expect(statusCell).toContainText(/cancelled/i, { timeout: 5000 }); // await expect(statusCell).toContainText(/cancelled/i, { timeout: 5000 });
}); // });
}); // });
+254 -254
View File
@@ -1,297 +1,297 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ // /* eslint-disable @typescript-eslint/no-explicit-any */
import { expect, Frame, Locator, Page, test } from "@playwright/test"; // import { expect, Frame, Locator, Page, test } from "@playwright/test";
import { set } from "lodash"; // import { set } from "lodash";
import { ContainerCopy, getAccountName, TestAccount } from "../../fx"; // import { ContainerCopy, getAccountName, TestAccount } from "../../fx";
const VISIBLE_TIMEOUT_MS = 30 * 1000; // const VISIBLE_TIMEOUT_MS = 30 * 1000;
test.describe("Container Copy - Permission Screen Verification", () => { // test.describe("Container Copy - Permission Screen Verification", () => {
let page: Page; // let page: Page;
let wrapper: Locator; // let wrapper: Locator;
let panel: Locator; // let panel: Locator;
let frame: Frame; // let frame: Frame;
let sourceAccountName: string; // let sourceAccountName: string;
let targetAccountName: string; // let targetAccountName: string;
test.beforeEach("Setup for each test", async ({ browser }) => { // test.beforeEach("Setup for each test", async ({ browser }) => {
page = await browser.newPage(); // page = await browser.newPage();
({ wrapper, frame } = await ContainerCopy.open(page, TestAccount.SQL)); // ({ wrapper, frame } = await ContainerCopy.open(page, TestAccount.SQL));
targetAccountName = getAccountName(TestAccount.SQLContainerCopyOnly); // targetAccountName = getAccountName(TestAccount.SQLContainerCopyOnly);
sourceAccountName = getAccountName(TestAccount.SQL); // sourceAccountName = getAccountName(TestAccount.SQL);
}); // });
test.afterEach("Cleanup after each test", async () => { // test.afterEach("Cleanup after each test", async () => {
await page.unrouteAll({ behavior: "ignoreErrors" }); // await page.unrouteAll({ behavior: "ignoreErrors" });
await page.close(); // await page.close();
}); // });
test("Verify online container copy permissions panel functionality", async () => { // test("Verify online container copy permissions panel functionality", async () => {
test.skip(); // test.skip();
expect(wrapper).not.toBeNull(); // expect(wrapper).not.toBeNull();
// Verify all command bar buttons are visible // // Verify all command bar buttons are visible
await wrapper.locator(".commandBarContainer").waitFor({ state: "visible", timeout: VISIBLE_TIMEOUT_MS }); // await wrapper.locator(".commandBarContainer").waitFor({ state: "visible", timeout: VISIBLE_TIMEOUT_MS });
const createCopyJobButton = wrapper.getByTestId("CommandBar/Button:Create Copy Job"); // const createCopyJobButton = wrapper.getByTestId("CommandBar/Button:Create Copy Job");
await expect(createCopyJobButton).toBeVisible(); // await expect(createCopyJobButton).toBeVisible();
await expect(wrapper.getByTestId("CommandBar/Button:Refresh")).toBeVisible(); // await expect(wrapper.getByTestId("CommandBar/Button:Refresh")).toBeVisible();
await expect(wrapper.getByTestId("CommandBar/Button:Feedback")).toBeVisible(); // await expect(wrapper.getByTestId("CommandBar/Button:Feedback")).toBeVisible();
// Mock Resource Graph API — fires on auto-subscription selection to populate account dropdown // // Mock Resource Graph API — fires on auto-subscription selection to populate account dropdown
await page.route( // await page.route(
"https://management.azure.com/providers/Microsoft.ResourceGraph/resources?api-version=2021-03-01", // "https://management.azure.com/providers/Microsoft.ResourceGraph/resources?api-version=2021-03-01",
async (route) => { // async (route) => {
const request = route.request(); // const request = route.request();
if ( // if (
request.method() === "POST" && // request.method() === "POST" &&
(request.postDataJSON()?.query as string) === // (request.postDataJSON()?.query as string) ===
"resources | where type =~ 'microsoft.documentdb/databaseaccounts'" // "resources | where type =~ 'microsoft.documentdb/databaseaccounts'"
) { // ) {
const response = await route.fetch(); // const response = await route.fetch();
const responseData = await response.json(); // const responseData = await response.json();
if (responseData.data && Array.isArray(responseData.data)) { // if (responseData.data && Array.isArray(responseData.data)) {
responseData.data = responseData.data.map((d: any) => { // responseData.data = responseData.data.map((d: any) => {
d.properties.backupPolicy.type = "Periodic"; // d.properties.backupPolicy.type = "Periodic";
return d; // return d;
}); // });
} // }
await route.fulfill({ // await route.fulfill({
status: 200, // status: 200,
contentType: "application/json", // contentType: "application/json",
body: JSON.stringify(responseData), // body: JSON.stringify(responseData),
}); // });
} else { // } else {
await route.continue(); // await route.continue();
} // }
}, // },
{ times: 2 }, // { times: 2 },
); // );
// Open the Create Copy Job panel // // Open the Create Copy Job panel
await createCopyJobButton.click(); // await createCopyJobButton.click();
panel = frame.getByTestId("Panel:Create copy job"); // panel = frame.getByTestId("Panel:Create copy job");
await expect(panel).toBeVisible(); // await expect(panel).toBeVisible();
await expect(panel.getByRole("heading", { name: "Create copy job" })).toBeVisible(); // await expect(panel.getByRole("heading", { name: "Create copy job" })).toBeVisible();
// Select a different account for cross-account testing // // Select a different account for cross-account testing
const accountDropdown = panel.getByTestId("account-dropdown"); // const accountDropdown = panel.getByTestId("account-dropdown");
await accountDropdown.click(); // await accountDropdown.click();
const dropdownItemsWrapper = frame.locator("div.ms-Dropdown-items"); // const dropdownItemsWrapper = frame.locator("div.ms-Dropdown-items");
expect(await dropdownItemsWrapper.getAttribute("aria-label")).toEqual("Account"); // expect(await dropdownItemsWrapper.getAttribute("aria-label")).toEqual("Account");
const allDropdownItems = await dropdownItemsWrapper.locator(`button.ms-Dropdown-item[role='option']`).all(); // const allDropdownItems = await dropdownItemsWrapper.locator(`button.ms-Dropdown-item[role='option']`).all();
for (const item of allDropdownItems) { // for (const item of allDropdownItems) {
const testContent = (await item.textContent()) ?? ""; // const testContent = (await item.textContent()) ?? "";
if (testContent.trim() === targetAccountName.trim()) { // if (testContent.trim() === targetAccountName.trim()) {
await item.click(); // await item.click();
break; // break;
} // }
} // }
// Enable online migration mode // // Enable online migration mode
const migrationTypeContainer = panel.getByTestId("migration-type"); // const migrationTypeContainer = panel.getByTestId("migration-type");
const onlineCopyRadioButton = migrationTypeContainer.getByRole("radio", { name: /Online mode/i }); // const onlineCopyRadioButton = migrationTypeContainer.getByRole("radio", { name: /Online mode/i });
await onlineCopyRadioButton.click({ force: true }); // await onlineCopyRadioButton.click({ force: true });
await expect(migrationTypeContainer.getByTestId("migration-type-description-online")).toBeVisible(); // await expect(migrationTypeContainer.getByTestId("migration-type-description-online")).toBeVisible();
await panel.getByRole("button", { name: "Next" }).click(); // await panel.getByRole("button", { name: "Next" }).click();
// Verify Assign Permissions panel for online copy // // Verify Assign Permissions panel for online copy
const permissionScreen = panel.getByTestId("Panel:AssignPermissionsContainer"); // const permissionScreen = panel.getByTestId("Panel:AssignPermissionsContainer");
await expect(permissionScreen).toBeVisible(); // await expect(permissionScreen).toBeVisible();
await expect(permissionScreen.getByText("Online container copy", { exact: true })).toBeVisible(); // await expect(permissionScreen.getByText("Online container copy", { exact: true })).toBeVisible();
await expect(permissionScreen.getByText("Cross-account container copy", { exact: true })).toBeVisible(); // await expect(permissionScreen.getByText("Cross-account container copy", { exact: true })).toBeVisible();
// Setup API mocking for the source account // // Setup API mocking for the source account
await page.route(`**/Microsoft.DocumentDB/databaseAccounts/${sourceAccountName}**`, async (route) => { // await page.route(`**/Microsoft.DocumentDB/databaseAccounts/${sourceAccountName}**`, async (route) => {
const mockData = { // const mockData = {
identity: { // identity: {
type: "SystemAssigned", // type: "SystemAssigned",
principalId: "00-11-22-33", // principalId: "00-11-22-33",
}, // },
properties: { // properties: {
defaultIdentity: "SystemAssignedIdentity", // defaultIdentity: "SystemAssignedIdentity",
backupPolicy: { // backupPolicy: {
type: "Continuous", // type: "Continuous",
}, // },
capabilities: [{ name: "EnableOnlineContainerCopy" }], // capabilities: [{ name: "EnableOnlineContainerCopy" }],
}, // },
}; // };
if (route.request().method() === "GET") { // if (route.request().method() === "GET") {
const response = await route.fetch(); // const response = await route.fetch();
const actualData = await response.json(); // const actualData = await response.json();
const mergedData = { ...actualData }; // const mergedData = { ...actualData };
set(mergedData, "identity", mockData.identity); // set(mergedData, "identity", mockData.identity);
set(mergedData, "properties.defaultIdentity", mockData.properties.defaultIdentity); // set(mergedData, "properties.defaultIdentity", mockData.properties.defaultIdentity);
set(mergedData, "properties.backupPolicy", mockData.properties.backupPolicy); // set(mergedData, "properties.backupPolicy", mockData.properties.backupPolicy);
set(mergedData, "properties.capabilities", mockData.properties.capabilities); // set(mergedData, "properties.capabilities", mockData.properties.capabilities);
await route.fulfill({ // await route.fulfill({
status: 200, // status: 200,
contentType: "application/json", // contentType: "application/json",
body: JSON.stringify(mergedData), // body: JSON.stringify(mergedData),
}); // });
} else { // } else {
await route.continue(); // await route.continue();
} // }
}); // });
// Verify Point-in-Time Restore functionality // // Verify Point-in-Time Restore functionality
const expandedOnlineAccordionHeader = permissionScreen // const expandedOnlineAccordionHeader = permissionScreen
.getByTestId("permission-group-container-onlineConfigs") // .getByTestId("permission-group-container-onlineConfigs")
.locator("button[aria-expanded='true']"); // .locator("button[aria-expanded='true']");
await expect(expandedOnlineAccordionHeader).toBeVisible(); // await expect(expandedOnlineAccordionHeader).toBeVisible();
const accordionItem = expandedOnlineAccordionHeader // const accordionItem = expandedOnlineAccordionHeader
.locator("xpath=ancestor::*[contains(@class, 'fui-AccordionItem') or contains(@data-test, 'accordion-item')]") // .locator("xpath=ancestor::*[contains(@class, 'fui-AccordionItem') or contains(@data-test, 'accordion-item')]")
.first(); // .first();
const accordionPanel = accordionItem // const accordionPanel = accordionItem
.locator("[role='tabpanel'], .fui-AccordionPanel, [data-test*='panel']") // .locator("[role='tabpanel'], .fui-AccordionPanel, [data-test*='panel']")
.first(); // .first();
// Install clock mock and test PITR functionality // // Install clock mock and test PITR functionality
await page.clock.install({ time: new Date("2024-01-01T10:00:00Z") }); // await page.clock.install({ time: new Date("2024-01-01T10:00:00Z") });
const pitrBtn = accordionPanel.getByTestId("pointInTimeRestore:PrimaryBtn"); // const pitrBtn = accordionPanel.getByTestId("pointInTimeRestore:PrimaryBtn");
await expect(pitrBtn).toBeVisible(); // await expect(pitrBtn).toBeVisible();
await pitrBtn.click({ force: true }); // await pitrBtn.click({ force: true });
// Verify new page opens with correct URL pattern // // Verify new page opens with correct URL pattern
page.context().on("page", async (newPage) => { // page.context().on("page", async (newPage) => {
const expectedUrlEndPattern = new RegExp( // const expectedUrlEndPattern = new RegExp(
`/providers/Microsoft.(DocumentDB|DocumentDb)/databaseAccounts/${sourceAccountName}/backupRestore`, // `/providers/Microsoft.(DocumentDB|DocumentDb)/databaseAccounts/${sourceAccountName}/backupRestore`,
); // );
expect(newPage.url()).toMatch(expectedUrlEndPattern); // expect(newPage.url()).toMatch(expectedUrlEndPattern);
await newPage.close(); // await newPage.close();
}); // });
const loadingOverlay = frame.locator("[data-test='loading-overlay']"); // const loadingOverlay = frame.locator("[data-test='loading-overlay']");
await expect(loadingOverlay).toBeVisible(); // await expect(loadingOverlay).toBeVisible();
const refreshBtn = accordionPanel.getByTestId("pointInTimeRestore:RefreshBtn"); // const refreshBtn = accordionPanel.getByTestId("pointInTimeRestore:RefreshBtn");
await expect(refreshBtn).not.toBeVisible(); // await expect(refreshBtn).not.toBeVisible();
// Fast forward time by 11 minutes // // Fast forward time by 11 minutes
await page.clock.fastForward(11 * 60 * 1000); // await page.clock.fastForward(11 * 60 * 1000);
await expect(refreshBtn).toBeVisible({ timeout: 5000 }); // await expect(refreshBtn).toBeVisible({ timeout: 5000 });
await expect(pitrBtn).not.toBeVisible(); // await expect(pitrBtn).not.toBeVisible();
// Setup additional API mocks for role assignments and permissions // // Setup additional API mocks for role assignments and permissions
// In the redesigned flow, role assignments are checked on the SOURCE account (current account = sourceAccountName). // // In the redesigned flow, role assignments are checked on the SOURCE account (current account = sourceAccountName).
// The destination account (selectedAccountName) manages identity; source account holds the role assignments. // // The destination account (selectedAccountName) manages identity; source account holds the role assignments.
await page.route( // await page.route(
`**/Microsoft.DocumentDB/databaseAccounts/${sourceAccountName}/sqlRoleAssignments*`, // `**/Microsoft.DocumentDB/databaseAccounts/${sourceAccountName}/sqlRoleAssignments*`,
async (route) => { // async (route) => {
await route.fulfill({ // await route.fulfill({
status: 200, // status: 200,
contentType: "application/json", // contentType: "application/json",
body: JSON.stringify({ // body: JSON.stringify({
value: [ // value: [
{ // {
principalId: "00-11-22-33", // principalId: "00-11-22-33",
roleDefinitionId: `Microsoft.DocumentDB/databaseAccounts/${sourceAccountName}/77-88-99`, // roleDefinitionId: `Microsoft.DocumentDB/databaseAccounts/${sourceAccountName}/77-88-99`,
}, // },
], // ],
}), // }),
}); // });
}, // },
); // );
await page.route("**/Microsoft.DocumentDB/databaseAccounts/*/77-88-99**", async (route) => { // await page.route("**/Microsoft.DocumentDB/databaseAccounts/*/77-88-99**", async (route) => {
await route.fulfill({ // await route.fulfill({
status: 200, // status: 200,
contentType: "application/json", // contentType: "application/json",
body: JSON.stringify({ // body: JSON.stringify({
value: [ // value: [
{ // {
// Built-in Cosmos DB Data Contributor role (read-write), required by checkTargetHasReadWriteRoleOnSource // // Built-in Cosmos DB Data Contributor role (read-write), required by checkTargetHasReadWriteRoleOnSource
name: "00000000-0000-0000-0000-000000000002", // name: "00000000-0000-0000-0000-000000000002",
}, // },
], // ],
}), // }),
}); // });
}); // });
await page.route(`**/Microsoft.DocumentDB/databaseAccounts/${sourceAccountName}**`, async (route) => { // await page.route(`**/Microsoft.DocumentDB/databaseAccounts/${sourceAccountName}**`, async (route) => {
const mockData = { // const mockData = {
identity: { // identity: {
type: "SystemAssigned", // type: "SystemAssigned",
principalId: "00-11-22-33", // principalId: "00-11-22-33",
}, // },
properties: { // properties: {
defaultIdentity: "SystemAssignedIdentity", // defaultIdentity: "SystemAssignedIdentity",
backupPolicy: { // backupPolicy: {
type: "Continuous", // type: "Continuous",
}, // },
capabilities: [{ name: "EnableOnlineContainerCopy" }], // capabilities: [{ name: "EnableOnlineContainerCopy" }],
}, // },
}; // };
if (route.request().method() === "PATCH") { // if (route.request().method() === "PATCH") {
await route.fulfill({ // await route.fulfill({
status: 200, // status: 200,
contentType: "application/json", // contentType: "application/json",
body: JSON.stringify({ status: "Succeeded" }), // body: JSON.stringify({ status: "Succeeded" }),
}); // });
} else if (route.request().method() === "GET") { // } else if (route.request().method() === "GET") {
const response = await route.fetch(); // const response = await route.fetch();
const actualData = await response.json(); // const actualData = await response.json();
const mergedData = { ...actualData }; // const mergedData = { ...actualData };
set(mergedData, "identity", mockData.identity); // set(mergedData, "identity", mockData.identity);
set(mergedData, "properties.defaultIdentity", mockData.properties.defaultIdentity); // set(mergedData, "properties.defaultIdentity", mockData.properties.defaultIdentity);
set(mergedData, "properties.backupPolicy", mockData.properties.backupPolicy); // set(mergedData, "properties.backupPolicy", mockData.properties.backupPolicy);
set(mergedData, "properties.capabilities", mockData.properties.capabilities); // set(mergedData, "properties.capabilities", mockData.properties.capabilities);
await route.fulfill({ // await route.fulfill({
status: 200, // status: 200,
contentType: "application/json", // contentType: "application/json",
body: JSON.stringify(mergedData), // body: JSON.stringify(mergedData),
}); // });
} else { // } else {
await route.continue(); // await route.continue();
} // }
}); // });
// Verify cross-account permissions functionality // // Verify cross-account permissions functionality
const expandedCrossAccordionHeader = permissionScreen // const expandedCrossAccordionHeader = permissionScreen
.getByTestId("permission-group-container-crossAccountConfigs") // .getByTestId("permission-group-container-crossAccountConfigs")
.locator("button[aria-expanded='true']"); // .locator("button[aria-expanded='true']");
await expect(expandedCrossAccordionHeader).toBeVisible(); // await expect(expandedCrossAccordionHeader).toBeVisible();
const crossAccordionItem = expandedCrossAccordionHeader // const crossAccordionItem = expandedCrossAccordionHeader
.locator("xpath=ancestor::*[contains(@class, 'fui-AccordionItem') or contains(@data-test, 'accordion-item')]") // .locator("xpath=ancestor::*[contains(@class, 'fui-AccordionItem') or contains(@data-test, 'accordion-item')]")
.first(); // .first();
const crossAccordionPanel = crossAccordionItem // const crossAccordionPanel = crossAccordionItem
.locator("[role='tabpanel'], .fui-AccordionPanel, [data-test*='panel']") // .locator("[role='tabpanel'], .fui-AccordionPanel, [data-test*='panel']")
.first(); // .first();
const toggleButton = crossAccordionPanel.getByTestId("btn-toggle"); // const toggleButton = crossAccordionPanel.getByTestId("btn-toggle");
await expect(toggleButton).toBeVisible(); // await expect(toggleButton).toBeVisible();
await toggleButton.click({ force: true }); // await toggleButton.click({ force: true });
// Verify popover functionality // // Verify popover functionality
const popover = frame.locator("[data-test='popover-container']"); // const popover = frame.locator("[data-test='popover-container']");
await expect(popover).toBeVisible(); // await expect(popover).toBeVisible();
const yesButton = popover.getByRole("button", { name: /Yes/i }); // const yesButton = popover.getByRole("button", { name: /Yes/i });
const noButton = popover.getByRole("button", { name: /No/i }); // const noButton = popover.getByRole("button", { name: /No/i });
await expect(yesButton).toBeVisible(); // await expect(yesButton).toBeVisible();
await expect(noButton).toBeVisible(); // await expect(noButton).toBeVisible();
await yesButton.click({ force: true }); // await yesButton.click({ force: true });
// Verify loading states // // Verify loading states
await expect(loadingOverlay).toBeVisible(); // await expect(loadingOverlay).toBeVisible();
await expect(loadingOverlay).toBeHidden({ timeout: 10 * 1000 }); // await expect(loadingOverlay).toBeHidden({ timeout: 10 * 1000 });
await expect(popover).toBeHidden({ timeout: 10 * 1000 }); // await expect(popover).toBeHidden({ timeout: 10 * 1000 });
// Cancel the panel to clean up // // Cancel the panel to clean up
await panel.getByRole("button", { name: "Cancel" }).click({ force: true }); // await panel.getByRole("button", { name: "Cancel" }).click({ force: true });
}); // });
}); // });
+171 -171
View File
@@ -1,212 +1,212 @@
import { expect, test } from "@playwright/test"; // import { expect, test } from "@playwright/test";
import { existsSync, mkdtempSync, rmdirSync, unlinkSync, writeFileSync } from "fs"; // import { existsSync, mkdtempSync, rmdirSync, unlinkSync, writeFileSync } from "fs";
import { tmpdir } from "os"; // import { tmpdir } from "os";
import path from "path"; // import path from "path";
import { CommandBarButton, DataExplorer, DocumentsTab, ONE_MINUTE_MS, TestAccount } from "../fx"; // import { CommandBarButton, DataExplorer, DocumentsTab, ONE_MINUTE_MS, TestAccount } from "../fx";
import { // import {
createTestSQLContainer, // createTestSQLContainer,
itemsPerPartition, // itemsPerPartition,
partitionCount, // partitionCount,
retry, // retry,
setPartitionKeys, // setPartitionKeys,
TestContainerContext, // TestContainerContext,
TestData, // TestData,
} from "../testData"; // } from "../testData";
import { documentTestCases } from "./testCases"; // import { documentTestCases } from "./testCases";
let explorer: DataExplorer = null!; // let explorer: DataExplorer = null!;
let documentsTab: DocumentsTab = null!; // let documentsTab: DocumentsTab = null!;
for (const { name, databaseId, containerId, documents } of documentTestCases) { // for (const { name, databaseId, containerId, documents } of documentTestCases) {
test.describe(`Test SQL Documents with ${name}`, () => { // test.describe(`Test SQL Documents with ${name}`, () => {
// test.skip(true, "Temporarily disabling all tests in this spec file"); // // test.skip(true, "Temporarily disabling all tests in this spec file");
test.beforeEach("Open documents tab", async ({ page }) => { // test.beforeEach("Open documents tab", async ({ page }) => {
explorer = await DataExplorer.open(page, TestAccount.SQLReadOnly); // explorer = await DataExplorer.open(page, TestAccount.SQLReadOnly);
const containerNode = await explorer.waitForContainerNode(databaseId, containerId); // const containerNode = await explorer.waitForContainerNode(databaseId, containerId);
await containerNode.expand(); // await containerNode.expand();
const containerMenuNode = await explorer.waitForContainerItemsNode(databaseId, containerId); // const containerMenuNode = await explorer.waitForContainerItemsNode(databaseId, containerId);
await containerMenuNode.element.click(); // await containerMenuNode.element.click();
documentsTab = explorer.documentsTab("tab0"); // documentsTab = explorer.documentsTab("tab0");
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 });
}); // });
for (const document of documents) { // for (const document of documents) {
const { documentId: docId, partitionKeys, skipCreateDelete } = document; // const { documentId: docId, partitionKeys, skipCreateDelete } = document;
test.describe(`Document ID: ${docId}`, () => { // test.describe(`Document ID: ${docId}`, () => {
test(`should load and view document ${docId}`, async () => { // test(`should load and view document ${docId}`, async () => {
test.skip(); // test.skip();
const span = documentsTab.documentsListPane.getByText(docId, { exact: true }).nth(0); // const span = documentsTab.documentsListPane.getByText(docId, { exact: true }).nth(0);
await span.waitFor(); // await span.waitFor();
await expect(span).toBeVisible(); // await expect(span).toBeVisible();
await span.click(); // await span.click();
await expect(documentsTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 }); // await expect(documentsTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 });
const resultText = await documentsTab.resultsEditor.text(); // const resultText = await documentsTab.resultsEditor.text();
const resultData = JSON.parse(resultText!); // const resultData = JSON.parse(resultText!);
expect(resultText).not.toBeNull(); // expect(resultText).not.toBeNull();
expect(resultData?.id).toEqual(docId); // expect(resultData?.id).toEqual(docId);
}); // });
const testOrSkip = skipCreateDelete ? test.skip : test; // const testOrSkip = skipCreateDelete ? test.skip : test;
testOrSkip(`should be able to create and delete new document from ${docId}`, async ({ page }) => { // testOrSkip(`should be able to create and delete new document from ${docId}`, async ({ page }) => {
test.skip(); // test.skip();
const span = documentsTab.documentsListPane.getByText(docId, { exact: true }).nth(0); // const span = documentsTab.documentsListPane.getByText(docId, { exact: true }).nth(0);
await span.waitFor(); // await span.waitFor();
await expect(span).toBeVisible(); // await expect(span).toBeVisible();
await span.click(); // await span.click();
let newDocumentId; // let newDocumentId;
await page.waitForTimeout(5000); // await page.waitForTimeout(5000);
await retry(async () => { // await retry(async () => {
const newDocumentButton = await explorer.waitForCommandBarButton("New Item", 5000); // const newDocumentButton = await explorer.waitForCommandBarButton("New Item", 5000);
await expect(newDocumentButton).toBeVisible(); // await expect(newDocumentButton).toBeVisible();
await expect(newDocumentButton).toBeEnabled(); // await expect(newDocumentButton).toBeEnabled();
await newDocumentButton.click(); // await newDocumentButton.click();
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 = { // const newDocument = {
id: newDocumentId, // id: newDocumentId,
...setPartitionKeys(partitionKeys || []), // ...setPartitionKeys(partitionKeys || []),
}; // };
await documentsTab.resultsEditor.setText(JSON.stringify(newDocument)); // await documentsTab.resultsEditor.setText(JSON.stringify(newDocument));
const saveButton = await explorer.waitForCommandBarButton("Save", 5000); // const saveButton = await explorer.waitForCommandBarButton("Save", 5000);
await saveButton.click({ timeout: 5000 }); // await saveButton.click({ timeout: 5000 });
await expect(saveButton).toBeHidden({ timeout: 5000 }); // await expect(saveButton).toBeHidden({ timeout: 5000 });
}, 3); // }, 3);
await documentsTab.setFilter(`WHERE c.id = "${newDocumentId}"`); // await documentsTab.setFilter(`WHERE c.id = "${newDocumentId}"`);
await documentsTab.filterButton.click(); // await documentsTab.filterButton.click();
const newSpan = documentsTab.documentsListPane.getByText(newDocumentId, { exact: true }).nth(0); // const newSpan = documentsTab.documentsListPane.getByText(newDocumentId, { exact: true }).nth(0);
await newSpan.waitFor(); // await newSpan.waitFor();
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("Delete", 5000);
await deleteButton.click(); // await deleteButton.click();
const deleteDialogButton = await explorer.waitForDialogButton("Delete", 5000); // const deleteDialogButton = await explorer.waitForDialogButton("Delete", 5000);
await deleteDialogButton.click(); // await deleteDialogButton.click();
const deletedSpan = documentsTab.documentsListPane.getByText(newDocumentId, { exact: true }).nth(0); // const deletedSpan = documentsTab.documentsListPane.getByText(newDocumentId, { exact: true }).nth(0);
await expect(deletedSpan).toHaveCount(0); // await expect(deletedSpan).toHaveCount(0);
}); // });
}); // });
} // }
}); // });
} // }
test.describe.serial("Upload Item", () => { // test.describe.serial("Upload Item", () => {
let context: TestContainerContext = null!; // let context: TestContainerContext = null!;
let uploadDocumentDirPath: string = null!; // let uploadDocumentDirPath: string = null!;
let uploadDocumentFilePath: string = null!; // let uploadDocumentFilePath: string = null!;
test.beforeAll("Create Test database and open documents tab", async ({ browser }) => { // test.beforeAll("Create Test database and open documents tab", async ({ browser }) => {
uploadDocumentDirPath = mkdtempSync(path.join(tmpdir(), "upload-document-")); // uploadDocumentDirPath = mkdtempSync(path.join(tmpdir(), "upload-document-"));
uploadDocumentFilePath = path.join(uploadDocumentDirPath, "uploadDocument.json"); // uploadDocumentFilePath = path.join(uploadDocumentDirPath, "uploadDocument.json");
const page = await browser.newPage(); // const page = await browser.newPage();
context = await createTestSQLContainer(); // context = await createTestSQLContainer();
explorer = await DataExplorer.open(page, TestAccount.SQL); // explorer = await DataExplorer.open(page, TestAccount.SQL);
const containerNode = await explorer.waitForContainerNode(context.database.id, context.container.id); // const containerNode = await explorer.waitForContainerNode(context.database.id, context.container.id);
await containerNode.expand(); // await containerNode.expand();
const containerMenuNode = await explorer.waitForContainerItemsNode(context.database.id, context.container.id); // const containerMenuNode = await explorer.waitForContainerItemsNode(context.database.id, context.container.id);
await containerMenuNode.element.click(); // await containerMenuNode.element.click();
// We need to click twice in order to remove a tooltip // // We need to click twice in order to remove a tooltip
await containerMenuNode.element.click(); // await containerMenuNode.element.click();
}); // });
test.afterAll("Delete Test Database and uploadDocument temp folder", async () => { // test.afterAll("Delete Test Database and uploadDocument temp folder", async () => {
if (existsSync(uploadDocumentFilePath)) { // if (existsSync(uploadDocumentFilePath)) {
unlinkSync(uploadDocumentFilePath); // unlinkSync(uploadDocumentFilePath);
} // }
if (existsSync(uploadDocumentDirPath)) { // if (existsSync(uploadDocumentDirPath)) {
rmdirSync(uploadDocumentDirPath); // rmdirSync(uploadDocumentDirPath);
} // }
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 () => {
const closeUploadItemsPanelButton = explorer.frame.getByLabel("Close Upload Items"); // const closeUploadItemsPanelButton = explorer.frame.getByLabel("Close Upload Items");
if (await closeUploadItemsPanelButton.isVisible()) { // if (await closeUploadItemsPanelButton.isVisible()) {
await closeUploadItemsPanelButton.click(); // await closeUploadItemsPanelButton.click();
} // }
}); // });
test("upload document", async () => { // test("upload document", async () => {
test.skip(); // test.skip();
// Create file to upload // // Create file to upload
const TestDataJsonString: string = JSON.stringify(TestData, null, 2); // const TestDataJsonString: string = JSON.stringify(TestData, null, 2);
writeFileSync(uploadDocumentFilePath, TestDataJsonString); // writeFileSync(uploadDocumentFilePath, TestDataJsonString);
const uploadItemCommandBar = explorer.commandBarButton(CommandBarButton.UploadItem); // const uploadItemCommandBar = explorer.commandBarButton(CommandBarButton.UploadItem);
await uploadItemCommandBar.click(); // await uploadItemCommandBar.click();
// Select file to upload // // Select file to upload
await explorer.frame.setInputFiles("#importFileInput", uploadDocumentFilePath); // await explorer.frame.setInputFiles("#importFileInput", uploadDocumentFilePath);
const uploadButton = explorer.frame.getByTestId("Panel/OkButton"); // const uploadButton = explorer.frame.getByTestId("Panel/OkButton");
await uploadButton.click(); // await uploadButton.click();
// Verify upload success message // // Verify upload success message
const fileUploadStatusExpected: string = `${partitionCount * itemsPerPartition} created, 0 throttled, 0 errors`; // const fileUploadStatusExpected: string = `${partitionCount * itemsPerPartition} created, 0 throttled, 0 errors`;
const fileUploadStatus = explorer.frame.getByTestId("file-upload-status"); // const fileUploadStatus = explorer.frame.getByTestId("file-upload-status");
await expect(fileUploadStatus).toContainText(fileUploadStatusExpected, { // await expect(fileUploadStatus).toContainText(fileUploadStatusExpected, {
timeout: ONE_MINUTE_MS, // timeout: ONE_MINUTE_MS,
}); // });
// Select file to upload again // // Select file to upload again
await explorer.frame.setInputFiles("#importFileInput", uploadDocumentFilePath); // await explorer.frame.setInputFiles("#importFileInput", uploadDocumentFilePath);
await uploadButton.click(); // await uploadButton.click();
// Verify upload failure message // // Verify upload failure message
const errorIcon = explorer.frame.getByRole("img", { name: "error" }); // const errorIcon = explorer.frame.getByRole("img", { name: "error" });
await expect(errorIcon).toBeVisible({ timeout: ONE_MINUTE_MS }); // await expect(errorIcon).toBeVisible({ timeout: ONE_MINUTE_MS });
await expect(fileUploadStatus).toContainText( // await expect(fileUploadStatus).toContainText(
`0 created, 0 throttled, ${partitionCount * itemsPerPartition} errors`, // `0 created, 0 throttled, ${partitionCount * itemsPerPartition} errors`,
{ // {
timeout: ONE_MINUTE_MS, // timeout: ONE_MINUTE_MS,
}, // },
); // );
}); // });
test("upload invalid json", async () => { // test("upload invalid json", async () => {
test.skip(); // test.skip();
// Create file to upload // // Create file to upload
let TestDataJsonString: string = JSON.stringify(TestData, null, 2); // let TestDataJsonString: string = JSON.stringify(TestData, null, 2);
// Remove the first '[' so that it becomes invalid json // // Remove the first '[' so that it becomes invalid json
TestDataJsonString = TestDataJsonString.substring(1); // TestDataJsonString = TestDataJsonString.substring(1);
writeFileSync(uploadDocumentFilePath, TestDataJsonString); // writeFileSync(uploadDocumentFilePath, TestDataJsonString);
const uploadItemCommandBar = explorer.commandBarButton(CommandBarButton.UploadItem); // const uploadItemCommandBar = explorer.commandBarButton(CommandBarButton.UploadItem);
await uploadItemCommandBar.click(); // await uploadItemCommandBar.click();
// Select file to upload // // Select file to upload
await explorer.frame.setInputFiles("#importFileInput", uploadDocumentFilePath); // await explorer.frame.setInputFiles("#importFileInput", uploadDocumentFilePath);
const uploadButton = explorer.frame.getByTestId("Panel/OkButton"); // const uploadButton = explorer.frame.getByTestId("Panel/OkButton");
await uploadButton.click(); // await uploadButton.click();
// Verify upload failure message // // Verify upload failure message
const fileUploadErrorList = explorer.frame.getByLabel("error list"); // const fileUploadErrorList = explorer.frame.getByLabel("error list");
// The parsing error will show up differently in different browsers so just check for the word "JSON" // // The parsing error will show up differently in different browsers so just check for the word "JSON"
await expect(fileUploadErrorList).toContainText("JSON", { // await expect(fileUploadErrorList).toContainText("JSON", {
timeout: ONE_MINUTE_MS, // timeout: ONE_MINUTE_MS,
}); // });
}); // });
}); // });
+85 -85
View File
@@ -1,109 +1,109 @@
import { expect, test } from "@playwright/test"; // import { expect, test } from "@playwright/test";
import { DataExplorer, TestAccount } from "../fx"; // import { DataExplorer, TestAccount } from "../fx";
import { createTestSQLContainer, TestContainerContext } from "../testData"; // import { createTestSQLContainer, TestContainerContext } from "../testData";
let context: TestContainerContext = null!; // let context: TestContainerContext = null!;
let explorer: DataExplorer = null!; // let explorer: DataExplorer = null!;
test.beforeAll("Create Test Database", async () => { // test.beforeAll("Create Test Database", async () => {
context = await createTestSQLContainer({ includeTestData: false }); // context = await createTestSQLContainer({ includeTestData: false });
}); // });
test.afterAll("Delete Test Database", async () => { // test.afterAll("Delete Test Database", async () => {
await context?.dispose(); // await context?.dispose();
}); // });
test.beforeEach("Open Data Explorer", async ({ page }) => { // test.beforeEach("Open Data Explorer", async ({ page }) => {
explorer = await DataExplorer.open(page, TestAccount.SQL); // explorer = await DataExplorer.open(page, TestAccount.SQL);
}); // });
test("Duplicate Items tab opens a second Items tab", async () => { // test("Duplicate Items tab opens a second Items tab", async () => {
test.skip(); // test.skip();
// Open Items tab // // Open Items tab
const containerNode = await explorer.waitForContainerNode(context.database.id, context.container.id); // const containerNode = await explorer.waitForContainerNode(context.database.id, context.container.id);
await containerNode.expand(); // await containerNode.expand();
const itemsNode = await explorer.waitForContainerItemsNode(context.database.id, context.container.id); // const itemsNode = await explorer.waitForContainerItemsNode(context.database.id, context.container.id);
await itemsNode.element.click(); // await itemsNode.element.click();
const documentsTab = explorer.documentsTab("tab0"); // const documentsTab = explorer.documentsTab("tab0");
await documentsTab.documentsFilter.waitFor({ timeout: 30_000 }); // await documentsTab.documentsFilter.waitFor({ timeout: 30_000 });
// Right-click the tab nav header // // Right-click the tab nav header
await explorer.tabNavHeader("tab0").click({ button: "right" }); // await explorer.tabNavHeader("tab0").click({ button: "right" });
// "Duplicate tab" should be visible in the context menu // // "Duplicate tab" should be visible in the context menu
const duplicateMenuItem = explorer.tabContextMenuItem("Duplicate tab"); // const duplicateMenuItem = explorer.tabContextMenuItem("Duplicate tab");
await expect(duplicateMenuItem).toBeVisible(); // await expect(duplicateMenuItem).toBeVisible();
await duplicateMenuItem.click(); // await duplicateMenuItem.click();
// A second tab should appear // // A second tab should appear
const tab1 = explorer.tab("tab1"); // const tab1 = explorer.tab("tab1");
await expect(tab1).toBeAttached({ timeout: 30_000 }); // await expect(tab1).toBeAttached({ timeout: 30_000 });
// The duplicated tab should also show the Documents content // // The duplicated tab should also show the Documents content
const duplicatedTab = explorer.documentsTab("tab1"); // const duplicatedTab = explorer.documentsTab("tab1");
await duplicatedTab.documentsFilter.waitFor({ timeout: 30_000 }); // await duplicatedTab.documentsFilter.waitFor({ timeout: 30_000 });
}); // });
test("Duplicate Query tab preserves query text in new tab", async () => { // test("Duplicate Query tab preserves query text in new tab", async () => {
test.skip(); // test.skip();
// Open a new SQL query tab via container context menu // // Open a new SQL query tab via container context menu
const containerNode = await explorer.waitForContainerNode(context.database.id, context.container.id); // const containerNode = await explorer.waitForContainerNode(context.database.id, context.container.id);
await containerNode.openContextMenu(); // await containerNode.openContextMenu();
await containerNode.contextMenuItem("New SQL Query").click(); // await containerNode.contextMenuItem("New SQL Query").click();
const queryTab = explorer.queryTab("tab0"); // const queryTab = explorer.queryTab("tab0");
const editor = queryTab.editor(); // const editor = queryTab.editor();
await editor.locator.waitFor({ timeout: 30_000 }); // await editor.locator.waitFor({ timeout: 30_000 });
// Type a custom query // // Type a custom query
const customQuery = 'SELECT * FROM c WHERE c.id = "duplicate-query-test"'; // const customQuery = 'SELECT * FROM c WHERE c.id = "duplicate-query-test"';
await editor.setText(customQuery); // await editor.setText(customQuery);
// Right-click the tab nav header // // Right-click the tab nav header
await explorer.tabNavHeader("tab0").click({ button: "right" }); // await explorer.tabNavHeader("tab0").click({ button: "right" });
const duplicateMenuItem = explorer.tabContextMenuItem("Duplicate tab"); // const duplicateMenuItem = explorer.tabContextMenuItem("Duplicate tab");
await expect(duplicateMenuItem).toBeVisible(); // await expect(duplicateMenuItem).toBeVisible();
await duplicateMenuItem.click(); // await duplicateMenuItem.click();
// Second query tab should appear // // Second query tab should appear
const tab1 = explorer.tab("tab1"); // const tab1 = explorer.tab("tab1");
await expect(tab1).toBeAttached({ timeout: 30_000 }); // await expect(tab1).toBeAttached({ timeout: 30_000 });
// The duplicated tab should contain the same query text // // The duplicated tab should contain the same query text
const duplicatedQueryTab = explorer.queryTab("tab1"); // const duplicatedQueryTab = explorer.queryTab("tab1");
await duplicatedQueryTab.editor().locator.waitFor({ timeout: 30_000 }); // await duplicatedQueryTab.editor().locator.waitFor({ timeout: 30_000 });
const editorText = await duplicatedQueryTab.editor().text(); // const editorText = await duplicatedQueryTab.editor().text();
expect(editorText).toContain("duplicate-query-test"); // expect(editorText).toContain("duplicate-query-test");
}); // });
test("Right-click context menu does not appear for the Home tab", async () => { // test("Right-click context menu does not appear for the Home tab", async () => {
test.skip(); // test.skip();
// The Home tab (ReactTabKind) is never duplicable — no context menu should appear // // The Home tab (ReactTabKind) is never duplicable — no context menu should appear
await explorer.tabNavHeader("Home").click({ button: "right" }); // await explorer.tabNavHeader("Home").click({ button: "right" });
// Neither menu item should be visible // // Neither menu item should be visible
await expect(explorer.tabContextMenuItem("Duplicate tab")).not.toBeVisible(); // await expect(explorer.tabContextMenuItem("Duplicate tab")).not.toBeVisible();
await expect(explorer.tabContextMenuItem("Close tab")).not.toBeVisible(); // await expect(explorer.tabContextMenuItem("Close tab")).not.toBeVisible();
}); // });
test("Close tab from right-click menu closes the tab", async () => { // test("Close tab from right-click menu closes the tab", async () => {
test.skip(); // test.skip();
// Open Items tab // // Open Items tab
const containerNode = await explorer.waitForContainerNode(context.database.id, context.container.id); // const containerNode = await explorer.waitForContainerNode(context.database.id, context.container.id);
await containerNode.expand(); // await containerNode.expand();
const itemsNode = await explorer.waitForContainerItemsNode(context.database.id, context.container.id); // const itemsNode = await explorer.waitForContainerItemsNode(context.database.id, context.container.id);
await itemsNode.element.click(); // await itemsNode.element.click();
const documentsTab = explorer.documentsTab("tab0"); // const documentsTab = explorer.documentsTab("tab0");
await documentsTab.documentsFilter.waitFor({ timeout: 30_000 }); // await documentsTab.documentsFilter.waitFor({ timeout: 30_000 });
// Right-click the tab nav header and close the tab // // Right-click the tab nav header and close the tab
await explorer.tabNavHeader("tab0").click({ button: "right" }); // await explorer.tabNavHeader("tab0").click({ button: "right" });
await explorer.tabContextMenuItem("Close tab").click(); // await explorer.tabContextMenuItem("Close tab").click();
// The tab pane should be removed // // The tab pane should be removed
await expect(explorer.tab("tab0")).not.toBeAttached({ timeout: 15_000 }); // await expect(explorer.tab("tab0")).not.toBeAttached({ timeout: 15_000 });
}); // });
+117 -117
View File
@@ -1,149 +1,149 @@
import { expect, test, type Page } from "@playwright/test"; // import { expect, test, type Page } from "@playwright/test";
import { CommandBarButton, DataExplorer, TestAccount } from "../fx"; // import { CommandBarButton, DataExplorer, TestAccount } from "../fx";
import { createTestSQLContainer, TestContainerContext } from "../testData"; // import { createTestSQLContainer, TestContainerContext } from "../testData";
// Test container context for setup and cleanup // // Test container context for setup and cleanup
let testContainer: TestContainerContext; // let testContainer: TestContainerContext;
let DATABASE_ID: string; // let DATABASE_ID: string;
let CONTAINER_ID: string; // let CONTAINER_ID: string;
// Set up test database and container with data before all tests // // Set up test database and container with data before all tests
test.beforeAll(async () => { // test.beforeAll(async () => {
testContainer = await createTestSQLContainer({ includeTestData: true }); // testContainer = await createTestSQLContainer({ includeTestData: true });
DATABASE_ID = testContainer.database.id; // DATABASE_ID = testContainer.database.id;
CONTAINER_ID = testContainer.container.id; // CONTAINER_ID = testContainer.container.id;
}); // });
// Clean up test database after all tests // // Clean up test database after all tests
test.afterAll(async () => { // test.afterAll(async () => {
if (testContainer) { // if (testContainer) {
await testContainer.dispose(); // await testContainer.dispose();
} // }
}); // });
// Helper function to set up query tab and navigate to Index Advisor // // Helper function to set up query tab and navigate to Index Advisor
async function setupIndexAdvisorTab(page: Page, customQuery?: string) { // async function setupIndexAdvisorTab(page: Page, customQuery?: string) {
const explorer = await DataExplorer.open(page, TestAccount.SQL); // const explorer = await DataExplorer.open(page, TestAccount.SQL);
const databaseNode = await explorer.waitForNode(DATABASE_ID); // const databaseNode = await explorer.waitForNode(DATABASE_ID);
await databaseNode.expand(); // await databaseNode.expand();
await page.waitForTimeout(2000); // await page.waitForTimeout(2000);
const containerNode = await explorer.waitForNode(`${DATABASE_ID}/${CONTAINER_ID}`); // const containerNode = await explorer.waitForNode(`${DATABASE_ID}/${CONTAINER_ID}`);
await containerNode.openContextMenu(); // await containerNode.openContextMenu();
await containerNode.contextMenuItem("New SQL Query").click(); // await containerNode.contextMenuItem("New SQL Query").click();
await page.waitForTimeout(2000); // await page.waitForTimeout(2000);
const queryTab = explorer.queryTab("tab0"); // const queryTab = explorer.queryTab("tab0");
const queryEditor = queryTab.editor(); // const queryEditor = queryTab.editor();
await queryEditor.locator.waitFor({ timeout: 30 * 1000 }); // await queryEditor.locator.waitFor({ timeout: 30 * 1000 });
await queryTab.executeCTA.waitFor(); // await queryTab.executeCTA.waitFor();
if (customQuery) { // if (customQuery) {
await queryEditor.locator.click(); // await queryEditor.locator.click();
await queryEditor.setText(customQuery); // await queryEditor.setText(customQuery);
} // }
const executeQueryButton = explorer.commandBarButton(CommandBarButton.ExecuteQuery); // const executeQueryButton = explorer.commandBarButton(CommandBarButton.ExecuteQuery);
await executeQueryButton.click(); // await executeQueryButton.click();
await expect(queryTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 }); // await expect(queryTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 });
const indexAdvisorTab = queryTab.resultsView.getByTestId("QueryTab/ResultsPane/ResultsView/IndexAdvisorTab"); // const indexAdvisorTab = queryTab.resultsView.getByTestId("QueryTab/ResultsPane/ResultsView/IndexAdvisorTab");
await indexAdvisorTab.click(); // await indexAdvisorTab.click();
await page.waitForTimeout(2000); // await page.waitForTimeout(2000);
return { explorer, queryTab, indexAdvisorTab }; // return { explorer, queryTab, indexAdvisorTab };
} // }
test("Index Advisor tab loads without errors", async ({ page }) => { // test("Index Advisor tab loads without errors", async ({ page }) => {
test.skip(); // test.skip();
const { indexAdvisorTab } = await setupIndexAdvisorTab(page); // const { indexAdvisorTab } = await setupIndexAdvisorTab(page);
await expect(indexAdvisorTab).toHaveAttribute("aria-selected", "true"); // await expect(indexAdvisorTab).toHaveAttribute("aria-selected", "true");
}); // });
test("Verify UI sections are collapsible", async ({ page }) => { // test("Verify UI sections are collapsible", async ({ page }) => {
test.skip(); // test.skip();
const { explorer } = await setupIndexAdvisorTab(page); // const { explorer } = await setupIndexAdvisorTab(page);
// Verify both section headers exist // // Verify both section headers exist
const includedHeader = explorer.frame.getByText("Included in Current Policy", { exact: true }); // const includedHeader = explorer.frame.getByText("Included in Current Policy", { exact: true });
const notIncludedHeader = explorer.frame.getByText("Not Included in Current Policy", { exact: true }); // const notIncludedHeader = explorer.frame.getByText("Not Included in Current Policy", { exact: true });
await expect(includedHeader).toBeVisible(); // await expect(includedHeader).toBeVisible();
await expect(notIncludedHeader).toBeVisible(); // await expect(notIncludedHeader).toBeVisible();
// Test collapsibility by checking if chevron/arrow icon changes state // // Test collapsibility by checking if chevron/arrow icon changes state
// Both sections should be expandable/collapsible regardless of content // // Both sections should be expandable/collapsible regardless of content
await includedHeader.click(); // await includedHeader.click();
await page.waitForTimeout(300); // await page.waitForTimeout(300);
await includedHeader.click(); // await includedHeader.click();
await page.waitForTimeout(300); // await page.waitForTimeout(300);
await notIncludedHeader.click(); // await notIncludedHeader.click();
await page.waitForTimeout(300); // await page.waitForTimeout(300);
await notIncludedHeader.click(); // await notIncludedHeader.click();
await page.waitForTimeout(300); // await page.waitForTimeout(300);
}); // });
test("Verify SDK response structure - Case 1: Empty response", async ({ page }) => { // test("Verify SDK response structure - Case 1: Empty response", async ({ page }) => {
test.skip(); // test.skip();
const { explorer } = await setupIndexAdvisorTab(page); // const { explorer } = await setupIndexAdvisorTab(page);
// Verify both section headers still exist even with no data // // Verify both section headers still exist even with no data
await expect(explorer.frame.getByText("Included in Current Policy", { exact: true })).toBeVisible(); // await expect(explorer.frame.getByText("Included in Current Policy", { exact: true })).toBeVisible();
await expect(explorer.frame.getByText("Not Included in Current Policy", { exact: true })).toBeVisible(); // await expect(explorer.frame.getByText("Not Included in Current Policy", { exact: true })).toBeVisible();
// Verify table headers // // Verify table headers
const table = explorer.frame.locator("table"); // const table = explorer.frame.locator("table");
await expect(table.getByText("Index", { exact: true })).toBeVisible(); // await expect(table.getByText("Index", { exact: true })).toBeVisible();
await expect(table.getByText("Estimated Impact", { exact: true })).toBeVisible(); // await expect(table.getByText("Estimated Impact", { exact: true })).toBeVisible();
// Verify "Update Indexing Policy" button is NOT visible when there are no potential indexes // // Verify "Update Indexing Policy" button is NOT visible when there are no potential indexes
const updateButton = explorer.frame.getByRole("button", { name: /Update Indexing Policy/i }); // const updateButton = explorer.frame.getByRole("button", { name: /Update Indexing Policy/i });
await expect(updateButton).not.toBeVisible(); // await expect(updateButton).not.toBeVisible();
}); // });
test("Verify index suggestions and apply potential index", async ({ page }) => { // test("Verify index suggestions and apply potential index", async ({ page }) => {
test.skip(); // test.skip();
const customQuery = 'SELECT * FROM c WHERE c.partitionKey = "partition_1" ORDER BY c.randomData'; // const customQuery = 'SELECT * FROM c WHERE c.partitionKey = "partition_1" ORDER BY c.randomData';
const { explorer } = await setupIndexAdvisorTab(page, customQuery); // const { explorer } = await setupIndexAdvisorTab(page, customQuery);
// Wait for Index Advisor to process the query // // Wait for Index Advisor to process the query
await page.waitForTimeout(2000); // await page.waitForTimeout(2000);
// Verify "Not Included in Current Policy" section has suggestions // // Verify "Not Included in Current Policy" section has suggestions
const notIncludedHeader = explorer.frame.getByText("Not Included in Current Policy", { exact: true }); // const notIncludedHeader = explorer.frame.getByText("Not Included in Current Policy", { exact: true });
await expect(notIncludedHeader).toBeVisible(); // await expect(notIncludedHeader).toBeVisible();
// Find the checkbox for the suggested composite index // // Find the checkbox for the suggested composite index
// The composite index should be /partitionKey ASC, /randomData ASC // // The composite index should be /partitionKey ASC, /randomData ASC
const checkboxes = explorer.frame.locator('input[type="checkbox"]'); // const checkboxes = explorer.frame.locator('input[type="checkbox"]');
const checkboxCount = await checkboxes.count(); // const checkboxCount = await checkboxes.count();
// Should have at least one checkbox for the potential index // // Should have at least one checkbox for the potential index
expect(checkboxCount).toBeGreaterThan(0); // expect(checkboxCount).toBeGreaterThan(0);
// Select the first checkbox (the high-impact composite index) // // Select the first checkbox (the high-impact composite index)
await checkboxes.first().check(); // await checkboxes.first().check();
await page.waitForTimeout(500); // await page.waitForTimeout(500);
// Verify "Update Indexing Policy" button becomes visible // // Verify "Update Indexing Policy" button becomes visible
const updateButton = explorer.frame.getByRole("button", { name: /Update Indexing Policy/i }); // const updateButton = explorer.frame.getByRole("button", { name: /Update Indexing Policy/i });
await expect(updateButton).toBeVisible(); // await expect(updateButton).toBeVisible();
// Click the "Update Indexing Policy" button // // Click the "Update Indexing Policy" button
await updateButton.click(); // await updateButton.click();
await page.waitForTimeout(1000); // await page.waitForTimeout(1000);
// Verify success message appears // // Verify success message appears
const successMessage = explorer.frame.getByText(/Your indexing policy has been updated with the new included paths/i); // const successMessage = explorer.frame.getByText(/Your indexing policy has been updated with the new included paths/i);
await expect(successMessage).toBeVisible(); // await expect(successMessage).toBeVisible();
// Verify the message mentions reviewing changes in Scale & Settings // // Verify the message mentions reviewing changes in Scale & Settings
const reviewMessage = explorer.frame.getByText(/You may review the changes in Scale & Settings/i); // const reviewMessage = explorer.frame.getByText(/You may review the changes in Scale & Settings/i);
await expect(reviewMessage).toBeVisible(); // await expect(reviewMessage).toBeVisible();
// Verify the checkmark icon is shown // // Verify the checkmark icon is shown
const checkmarkIcon = explorer.frame.locator('[data-icon-name="CheckMark"]'); // const checkmarkIcon = explorer.frame.locator('[data-icon-name="CheckMark"]');
await expect(checkmarkIcon).toBeVisible(); // await expect(checkmarkIcon).toBeVisible();
}); // });
+116 -116
View File
@@ -1,144 +1,144 @@
import { expect, test } from "@playwright/test"; // import { expect, test } from "@playwright/test";
import { CommandBarButton, DataExplorer, Editor, QueryTab, TestAccount } from "../fx"; // import { CommandBarButton, DataExplorer, Editor, QueryTab, TestAccount } from "../fx";
import { TestContainerContext, TestItem, createTestSQLContainer } from "../testData"; // import { TestContainerContext, TestItem, createTestSQLContainer } from "../testData";
let context: TestContainerContext = null!; // let context: TestContainerContext = null!;
let explorer: DataExplorer = null!; // let explorer: DataExplorer = null!;
let queryTab: QueryTab = null!; // let queryTab: QueryTab = null!;
let queryEditor: Editor = null!; // let queryEditor: Editor = null!;
test.beforeAll("Create Test Database", async () => { // test.beforeAll("Create Test Database", async () => {
context = await createTestSQLContainer({ includeTestData: true }); // context = await createTestSQLContainer({ includeTestData: true });
}); // });
test.beforeEach("Open new query tab", async ({ page }) => { // test.beforeEach("Open new query tab", async ({ page }) => {
// Open a query tab // // Open a query tab
explorer = await DataExplorer.open(page, TestAccount.SQL); // explorer = await DataExplorer.open(page, TestAccount.SQL);
// Container nodes should be visible. The explorer auto-expands database nodes when they are first loaded. // // Container nodes should be visible. The explorer auto-expands database nodes when they are first loaded.
const containerNode = await explorer.waitForContainerNode(context.database.id, context.container.id); // const containerNode = await explorer.waitForContainerNode(context.database.id, context.container.id);
await containerNode.openContextMenu(); // await containerNode.openContextMenu();
await containerNode.contextMenuItem("New SQL Query").click(); // await containerNode.contextMenuItem("New SQL Query").click();
// Wait for the editor to load // // Wait for the editor to load
queryTab = explorer.queryTab("tab0"); // queryTab = explorer.queryTab("tab0");
queryEditor = queryTab.editor(); // queryEditor = queryTab.editor();
await queryEditor.locator.waitFor({ timeout: 30 * 1000 }); // await queryEditor.locator.waitFor({ timeout: 30 * 1000 });
await queryTab.executeCTA.waitFor(); // await queryTab.executeCTA.waitFor();
await explorer.frame.getByTestId("NotificationConsole/ExpandCollapseButton").click(); // await explorer.frame.getByTestId("NotificationConsole/ExpandCollapseButton").click();
await explorer.frame.getByTestId("NotificationConsole/Contents").waitFor(); // await explorer.frame.getByTestId("NotificationConsole/Contents").waitFor();
}); // });
test.afterAll("Delete Test Database", async () => { // test.afterAll("Delete Test Database", async () => {
await context?.dispose(); // await context?.dispose();
}); // });
test("Query results", async () => { // test("Query results", async () => {
test.skip(); // test.skip();
// Run the query and verify the results // // Run the query and verify the results
await queryEditor.locator.click(); // await queryEditor.locator.click();
const executeQueryButton = explorer.commandBarButton(CommandBarButton.ExecuteQuery); // const executeQueryButton = explorer.commandBarButton(CommandBarButton.ExecuteQuery);
await executeQueryButton.click(); // await executeQueryButton.click();
await expect(queryTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 }); // await expect(queryTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 });
// Read the results // // Read the results
const resultText = await queryTab.resultsEditor.text(); // const resultText = await queryTab.resultsEditor.text();
expect(resultText).not.toBeNull(); // expect(resultText).not.toBeNull();
const resultData: TestItem[] = JSON.parse(resultText!); // const resultData: TestItem[] = JSON.parse(resultText!);
// Pick 3 random documents and assert them // // Pick 3 random documents and assert them
const randomDocs = [0, 1, 2].map(() => resultData[Math.floor(Math.random() * resultData.length)]); // const randomDocs = [0, 1, 2].map(() => resultData[Math.floor(Math.random() * resultData.length)]);
randomDocs.forEach((doc) => { // randomDocs.forEach((doc) => {
const matchingDoc = context?.testData.get(doc.id); // const matchingDoc = context?.testData.get(doc.id);
expect(matchingDoc).not.toBeNull(); // expect(matchingDoc).not.toBeNull();
expect(doc.randomData).toEqual(matchingDoc?.randomData); // expect(doc.randomData).toEqual(matchingDoc?.randomData);
expect(doc.partitionKey).toEqual(matchingDoc?.partitionKey); // expect(doc.partitionKey).toEqual(matchingDoc?.partitionKey);
}); // });
}); // });
test("Query stats", async () => { // test("Query stats", async () => {
test.skip(); // test.skip();
// Run the query and verify the results // // Run the query and verify the results
await queryEditor.locator.click(); // await queryEditor.locator.click();
const executeQueryButton = explorer.commandBarButton(CommandBarButton.ExecuteQuery); // const executeQueryButton = explorer.commandBarButton(CommandBarButton.ExecuteQuery);
await executeQueryButton.click(); // await executeQueryButton.click();
await expect(queryTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 }); // await expect(queryTab.resultsEditor.locator).toBeAttached({ timeout: 60 * 1000 });
// Open the query stats tab and validate some data there // // Open the query stats tab and validate some data there
queryTab.queryStatsTab.click(); // queryTab.queryStatsTab.click();
await expect(queryTab.queryStatsList).toBeAttached(); // await expect(queryTab.queryStatsList).toBeAttached();
const showingResultsCell = queryTab.queryStatsList.getByTestId("Row:Showing Results/Column:value"); // const showingResultsCell = queryTab.queryStatsList.getByTestId("Row:Showing Results/Column:value");
await expect(showingResultsCell).toContainText(/\d+ - \d+/); // await expect(showingResultsCell).toContainText(/\d+ - \d+/);
}); // });
test("Query errors", async () => { // test("Query errors", async () => {
test.skip(true, "Disabled due to an issue with error reporting in the backend."); // test.skip(true, "Disabled due to an issue with error reporting in the backend.");
await queryEditor.locator.click(); // await queryEditor.locator.click();
await queryEditor.setText("SELECT\n glarb(c.id),\n blarg(c.id)\nFROM c"); // await queryEditor.setText("SELECT\n glarb(c.id),\n blarg(c.id)\nFROM c");
// Run the query and verify the results // // Run the query and verify the results
const executeQueryButton = explorer.commandBarButton(CommandBarButton.ExecuteQuery); // const executeQueryButton = explorer.commandBarButton(CommandBarButton.ExecuteQuery);
await executeQueryButton.click(); // await executeQueryButton.click();
await expect(queryTab.errorList).toBeAttached({ timeout: 60 * 1000 }); // await expect(queryTab.errorList).toBeAttached({ timeout: 60 * 1000 });
// Validating the squiggles requires a lot of digging through the Monaco model, OR a screenshot comparison. // // Validating the squiggles requires a lot of digging through the Monaco model, OR a screenshot comparison.
// The screenshot ended up being fairly flaky, and a pain to maintain, so I decided not to include validation for the squiggles. // // The screenshot ended up being fairly flaky, and a pain to maintain, so I decided not to include validation for the squiggles.
// Validate the errors are in the list // // Validate the errors are in the list
await expect(queryTab.errorList.getByTestId("Row:0/Column:code")).toHaveText("SC2005"); // await expect(queryTab.errorList.getByTestId("Row:0/Column:code")).toHaveText("SC2005");
await expect(queryTab.errorList.getByTestId("Row:0/Column:location")).toHaveText("Line 2"); // await expect(queryTab.errorList.getByTestId("Row:0/Column:location")).toHaveText("Line 2");
await expect(queryTab.errorList.getByTestId("Row:1/Column:code")).toHaveText("SC2005"); // await expect(queryTab.errorList.getByTestId("Row:1/Column:code")).toHaveText("SC2005");
await expect(queryTab.errorList.getByTestId("Row:1/Column:location")).toHaveText("Line 3"); // await expect(queryTab.errorList.getByTestId("Row:1/Column:location")).toHaveText("Line 3");
}); // });
test("View button toggles between vertical and horizontal layout", async () => { // test("View button toggles between vertical and horizontal layout", async () => {
// The default layout is Horizontal (Allotment vertical={true} → split-view-vertical class) // // The default layout is Horizontal (Allotment vertical={true} → split-view-vertical class)
const allotment = queryTab.locator.locator(".split-view-vertical, .split-view-horizontal"); // const allotment = queryTab.locator.locator(".split-view-vertical, .split-view-horizontal");
await expect(allotment).toBeAttached(); // await expect(allotment).toBeAttached();
await expect(allotment).toHaveClass(/split-view-vertical/); // await expect(allotment).toHaveClass(/split-view-vertical/);
// Click the main View button (not the chevron) to toggle to Vertical layout // // Click the main View button (not the chevron) to toggle to Vertical layout
const viewButton = explorer.commandBarButton(CommandBarButton.View); // const viewButton = explorer.commandBarButton(CommandBarButton.View);
await viewButton.click(); // await viewButton.click();
// After toggle, Allotment should have split-view-horizontal class (Vertical direction) // // After toggle, Allotment should have split-view-horizontal class (Vertical direction)
const allotmentAfterToggle = queryTab.locator.locator(".split-view-vertical, .split-view-horizontal"); // const allotmentAfterToggle = queryTab.locator.locator(".split-view-vertical, .split-view-horizontal");
await expect(allotmentAfterToggle).toHaveClass(/split-view-horizontal/); // await expect(allotmentAfterToggle).toHaveClass(/split-view-horizontal/);
// Click again to toggle back to Horizontal // // Click again to toggle back to Horizontal
await viewButton.click(); // await viewButton.click();
const allotmentAfterSecondToggle = queryTab.locator.locator(".split-view-vertical, .split-view-horizontal"); // const allotmentAfterSecondToggle = queryTab.locator.locator(".split-view-vertical, .split-view-horizontal");
await expect(allotmentAfterSecondToggle).toHaveClass(/split-view-vertical/); // await expect(allotmentAfterSecondToggle).toHaveClass(/split-view-vertical/);
}); // });
test("View dropdown allows selecting vertical or horizontal layout", async () => { // test("View dropdown allows selecting vertical or horizontal layout", async () => {
test.skip(); // test.skip();
// The default layout is Horizontal (split-view-vertical) // // The default layout is Horizontal (split-view-vertical)
const allotment = queryTab.locator.locator(".split-view-vertical, .split-view-horizontal"); // const allotment = queryTab.locator.locator(".split-view-vertical, .split-view-horizontal");
await expect(allotment).toHaveClass(/split-view-vertical/); // await expect(allotment).toHaveClass(/split-view-vertical/);
// Find the View split button's menu trigger (chevron). // // Find the View split button's menu trigger (chevron).
// The primary button has data-test, so navigate to the split button container and find the menu button. // // The primary button has data-test, so navigate to the split button container and find the menu button.
const viewPrimaryButton = explorer.commandBarButton(CommandBarButton.View); // const viewPrimaryButton = explorer.commandBarButton(CommandBarButton.View);
const splitContainer = viewPrimaryButton.locator(".."); // const splitContainer = viewPrimaryButton.locator("..");
const menuButton = splitContainer.locator('[aria-haspopup="true"]'); // const menuButton = splitContainer.locator('[aria-haspopup="true"]');
await menuButton.click(); // await menuButton.click();
// Select "Vertical" from the dropdown menu // // Select "Vertical" from the dropdown menu
await explorer.frame.getByRole("menuitem", { name: "Vertical" }).click(); // await explorer.frame.getByRole("menuitem", { name: "Vertical" }).click();
// Verify the layout changed to Vertical (split-view-horizontal) // // Verify the layout changed to Vertical (split-view-horizontal)
const allotmentAfterVertical = queryTab.locator.locator(".split-view-vertical, .split-view-horizontal"); // const allotmentAfterVertical = queryTab.locator.locator(".split-view-vertical, .split-view-horizontal");
await expect(allotmentAfterVertical).toHaveClass(/split-view-horizontal/); // await expect(allotmentAfterVertical).toHaveClass(/split-view-horizontal/);
// Open dropdown again and select "Horizontal" // // Open dropdown again and select "Horizontal"
await menuButton.click(); // await menuButton.click();
await explorer.frame.getByRole("menuitem", { name: "Horizontal" }).click(); // await explorer.frame.getByRole("menuitem", { name: "Horizontal" }).click();
// Verify it reverted to Horizontal (split-view-vertical) // // Verify it reverted to Horizontal (split-view-vertical)
const allotmentAfterHorizontal = queryTab.locator.locator(".split-view-vertical, .split-view-horizontal"); // const allotmentAfterHorizontal = queryTab.locator.locator(".split-view-vertical, .split-view-horizontal");
await expect(allotmentAfterHorizontal).toHaveClass(/split-view-vertical/); // await expect(allotmentAfterHorizontal).toHaveClass(/split-view-vertical/);
}); // });
+52 -52
View File
@@ -1,60 +1,60 @@
import { expect, test } from "@playwright/test"; // import { expect, test } from "@playwright/test";
import { CosmosDBManagementClient } from "@azure/arm-cosmosdb"; // import { CosmosDBManagementClient } from "@azure/arm-cosmosdb";
import { CosmosClient, PermissionMode } from "@azure/cosmos"; // import { CosmosClient, PermissionMode } from "@azure/cosmos";
import { // import {
DataExplorer, // DataExplorer,
TestAccount, // TestAccount,
generateUniqueName, // generateUniqueName,
getAccountName, // getAccountName,
getAzureCLICredentials, // getAzureCLICredentials,
resourceGroupName, // resourceGroupName,
subscriptionId, // subscriptionId,
} from "../fx"; // } from "../fx";
import { getNoSqlRbacToken } from "../NoSqlTestSetup"; // import { getNoSqlRbacToken } from "../NoSqlTestSetup";
test("SQL account using Resource token", async ({ page }) => { // test("SQL account using Resource token", async ({ page }) => {
test.skip(); // test.skip();
const nosqlAccountRbacToken = getNoSqlRbacToken() ?? ""; // const nosqlAccountRbacToken = getNoSqlRbacToken() ?? "";
test.skip(nosqlAccountRbacToken.length > 0, "Resource tokens not supported when using data plane RBAC."); // test.skip(nosqlAccountRbacToken.length > 0, "Resource tokens not supported when using data plane RBAC.");
const credentials = getAzureCLICredentials(); // const credentials = getAzureCLICredentials();
const armClient = new CosmosDBManagementClient(credentials, subscriptionId); // const armClient = new CosmosDBManagementClient(credentials, subscriptionId);
const accountName = getAccountName(TestAccount.SQL); // const accountName = getAccountName(TestAccount.SQL);
const account = await armClient.databaseAccounts.get(resourceGroupName, accountName); // const account = await armClient.databaseAccounts.get(resourceGroupName, accountName);
const keys = await armClient.databaseAccounts.listKeys(resourceGroupName, accountName); // const keys = await armClient.databaseAccounts.listKeys(resourceGroupName, accountName);
const dbId = generateUniqueName("db"); // const dbId = generateUniqueName("db");
const collectionId = "testcollection"; // const collectionId = "testcollection";
const client = new CosmosClient({ // const client = new CosmosClient({
endpoint: account.documentEndpoint!, // endpoint: account.documentEndpoint!,
key: keys.primaryMasterKey, // key: keys.primaryMasterKey,
}); // });
const { database } = await client.databases.createIfNotExists({ id: dbId }); // const { database } = await client.databases.createIfNotExists({ id: dbId });
const { container } = await database.containers.createIfNotExists({ id: collectionId }); // const { container } = await database.containers.createIfNotExists({ id: collectionId });
const { user } = await database.users.upsert({ id: "testUser" }); // const { user } = await database.users.upsert({ id: "testUser" });
const { resource: containerPermission } = await user.permissions.upsert({ // const { resource: containerPermission } = await user.permissions.upsert({
id: "partitionLevelPermission", // id: "partitionLevelPermission",
permissionMode: PermissionMode.All, // permissionMode: PermissionMode.All,
resource: container.url, // resource: container.url,
}); // });
await expect(containerPermission).toBeDefined(); // await expect(containerPermission).toBeDefined();
const resourceTokenConnectionString = `AccountEndpoint=${account.documentEndpoint};DatabaseId=${ // const resourceTokenConnectionString = `AccountEndpoint=${account.documentEndpoint};DatabaseId=${
database.id // database.id
};CollectionId=${container.id};${containerPermission!._token}`; // };CollectionId=${container.id};${containerPermission!._token}`;
await page.goto("https://localhost:1234/hostedExplorer.html"); // await page.goto("https://localhost:1234/hostedExplorer.html");
const switchConnectionLink = page.getByTestId("Link:SwitchConnectionType"); // const switchConnectionLink = page.getByTestId("Link:SwitchConnectionType");
await switchConnectionLink.waitFor(); // await switchConnectionLink.waitFor();
await switchConnectionLink.click(); // await switchConnectionLink.click();
await page.getByPlaceholder("Please enter a connection string").fill(resourceTokenConnectionString); // await page.getByPlaceholder("Please enter a connection string").fill(resourceTokenConnectionString);
await page.getByRole("button", { name: "Connect" }).click(); // await page.getByRole("button", { name: "Connect" }).click();
const explorer = await DataExplorer.waitForExplorer(page); // const explorer = await DataExplorer.waitForExplorer(page);
const collectionNode = explorer.treeNode(`${collectionId}`); // const collectionNode = explorer.treeNode(`${collectionId}`);
await collectionNode.element.waitFor(); // await collectionNode.element.waitFor();
await expect(collectionNode.element).toBeAttached(); // await expect(collectionNode.element).toBeAttached();
await database.delete(); // await database.delete();
}); // });
@@ -1,140 +1,140 @@
import { expect, test } from "@playwright/test"; // import { expect, test } from "@playwright/test";
import { DataExplorer, TestAccount } from "../../fx"; // import { DataExplorer, TestAccount } from "../../fx";
import { createTestSQLContainer, TestContainerContext } from "../../testData"; // import { createTestSQLContainer, TestContainerContext } from "../../testData";
test.describe("Change Partition Key", () => { // test.describe("Change Partition Key", () => {
let context: TestContainerContext = null!; // let context: TestContainerContext = null!;
let explorer: DataExplorer = null!; // let explorer: DataExplorer = null!;
const newPartitionKeyPath = "newPartitionKey"; // const newPartitionKeyPath = "newPartitionKey";
const newContainerId = "testcontainer_1"; // const newContainerId = "testcontainer_1";
let previousJobName: string | undefined; // let previousJobName: string | undefined;
test.beforeAll("Create Test Database", async () => { // test.beforeAll("Create Test Database", async () => {
context = await createTestSQLContainer(); // context = await createTestSQLContainer();
}); // });
test.beforeEach("Open container settings", async ({ page }) => { // test.beforeEach("Open container settings", async ({ page }) => {
explorer = await DataExplorer.open(page, TestAccount.SQL); // explorer = await DataExplorer.open(page, TestAccount.SQL);
// Click Scale & Settings and open Partition Key tab // // Click Scale & Settings and open Partition Key tab
await explorer.openScaleAndSettings(context); // await explorer.openScaleAndSettings(context);
const PartitionKeyTab = explorer.frame.getByTestId("settings-tab-header/PartitionKeyTab"); // const PartitionKeyTab = explorer.frame.getByTestId("settings-tab-header/PartitionKeyTab");
await expect(PartitionKeyTab).toBeVisible(); // await expect(PartitionKeyTab).toBeVisible();
await PartitionKeyTab.click(); // await PartitionKeyTab.click();
}); // });
test.afterEach("Delete Test Database", async () => { // test.afterEach("Delete Test Database", async () => {
await context?.dispose(); // await context?.dispose();
}); // });
test("Change partition key path", async ({ page }) => { // test("Change partition key path", async ({ page }) => {
test.skip(); // test.skip();
await expect(explorer.frame.getByText("/partitionKey")).toBeVisible(); // await expect(explorer.frame.getByText("/partitionKey")).toBeVisible();
await expect(explorer.frame.getByText("Change partition key")).toBeVisible(); // await expect(explorer.frame.getByText("Change partition key")).toBeVisible();
await expect(explorer.frame.getByText(/To safeguard the integrity of/)).toBeVisible(); // await expect(explorer.frame.getByText(/To safeguard the integrity of/)).toBeVisible();
await expect(explorer.frame.getByText(/To change the partition key/)).toBeVisible(); // await expect(explorer.frame.getByText(/To change the partition key/)).toBeVisible();
const changePartitionKeyButton = explorer.frame.getByTestId("change-partition-key-button"); // const changePartitionKeyButton = explorer.frame.getByTestId("change-partition-key-button");
expect(changePartitionKeyButton).toBeVisible(); // expect(changePartitionKeyButton).toBeVisible();
await changePartitionKeyButton.click(); // await changePartitionKeyButton.click();
// Fill out new partition key form in the panel // // Fill out new partition key form in the panel
const changePkPanel = explorer.frame.getByTestId(`Panel:Change partition key`); // const changePkPanel = explorer.frame.getByTestId(`Panel:Change partition key`);
await expect(changePkPanel.getByText(context.database.id)).toBeVisible(); // await expect(changePkPanel.getByText(context.database.id)).toBeVisible();
await expect(explorer.frame.getByRole("heading", { name: "Change partition key" })).toBeVisible(); // await expect(explorer.frame.getByRole("heading", { name: "Change partition key" })).toBeVisible();
await expect(explorer.frame.getByText(/When changing a container/)).toBeVisible(); // await expect(explorer.frame.getByText(/When changing a container/)).toBeVisible();
// Try to switch to new container // // Try to switch to new container
await expect(changePkPanel.getByText("New container")).toBeVisible(); // await expect(changePkPanel.getByText("New container")).toBeVisible();
await expect(changePkPanel.getByText("Existing container")).toBeVisible(); // await expect(changePkPanel.getByText("Existing container")).toBeVisible();
await expect(changePkPanel.getByTestId("new-container-id-input")).toBeVisible(); // await expect(changePkPanel.getByTestId("new-container-id-input")).toBeVisible();
changePkPanel.getByTestId("new-container-id-input").fill(newContainerId); // changePkPanel.getByTestId("new-container-id-input").fill(newContainerId);
await expect(changePkPanel.getByTestId("new-container-partition-key-input")).toBeVisible(); // await expect(changePkPanel.getByTestId("new-container-partition-key-input")).toBeVisible();
changePkPanel.getByTestId("new-container-partition-key-input").fill(newPartitionKeyPath); // changePkPanel.getByTestId("new-container-partition-key-input").fill(newPartitionKeyPath);
await expect(changePkPanel.getByTestId("add-sub-partition-key-button")).toBeVisible(); // await expect(changePkPanel.getByTestId("add-sub-partition-key-button")).toBeVisible();
changePkPanel.getByTestId("add-sub-partition-key-button").click(); // changePkPanel.getByTestId("add-sub-partition-key-button").click();
await expect(changePkPanel.getByTestId("new-container-sub-partition-key-input-0")).toBeVisible(); // await expect(changePkPanel.getByTestId("new-container-sub-partition-key-input-0")).toBeVisible();
await expect(changePkPanel.getByTestId("remove-sub-partition-key-button-0")).toBeVisible(); // await expect(changePkPanel.getByTestId("remove-sub-partition-key-button-0")).toBeVisible();
await expect(changePkPanel.getByTestId("hierarchical-partitioning-info-text")).toBeVisible(); // await expect(changePkPanel.getByTestId("hierarchical-partitioning-info-text")).toBeVisible();
await changePkPanel.getByTestId("remove-sub-partition-key-button-0").click(); // await changePkPanel.getByTestId("remove-sub-partition-key-button-0").click();
await changePkPanel.getByTestId("Panel/OkButton").click(); // await changePkPanel.getByTestId("Panel/OkButton").click();
let jobName: string | undefined; // let jobName: string | undefined;
await page.waitForRequest( // await page.waitForRequest(
(req) => { // (req) => {
const requestUrl = req.url(); // const requestUrl = req.url();
if (requestUrl.includes("/dataTransferJobs") && req.method() === "PUT") { // if (requestUrl.includes("/dataTransferJobs") && req.method() === "PUT") {
jobName = new URL(requestUrl).pathname.split("/").pop(); // jobName = new URL(requestUrl).pathname.split("/").pop();
return true; // return true;
} // }
return false; // return false;
}, // },
{ timeout: 120000 }, // { timeout: 120000 },
); // );
await expect(changePkPanel).not.toBeVisible({ timeout: 5 * 60 * 1000 }); // await expect(changePkPanel).not.toBeVisible({ timeout: 5 * 60 * 1000 });
// Verify partition key change job // // Verify partition key change job
const jobText = explorer.frame.getByText(/Partition key change job/); // const jobText = explorer.frame.getByText(/Partition key change job/);
await expect(jobText).toBeVisible(); // await expect(jobText).toBeVisible();
// await expect(explorer.frame.locator(".ms-ProgressIndicator-itemName")).toContainText("Portal_testcontainer_1"); // // await expect(explorer.frame.locator(".ms-ProgressIndicator-itemName")).toContainText("Portal_testcontainer_1");
await expect(explorer.frame.locator(".ms-ProgressIndicator-itemName")).toContainText(jobName!); // await expect(explorer.frame.locator(".ms-ProgressIndicator-itemName")).toContainText(jobName!);
const jobRow = explorer.frame.locator(".ms-ProgressIndicator-itemDescription"); // const jobRow = explorer.frame.locator(".ms-ProgressIndicator-itemDescription");
// await expect(jobRow.getByText("Pending")).toBeVisible({ timeout: 30 * 1000 }); // // await expect(jobRow.getByText("Pending")).toBeVisible({ timeout: 30 * 1000 });
await expect(jobRow.getByText("Completed")).toBeVisible({ timeout: 5 * 60 * 1000 }); // await expect(jobRow.getByText("Completed")).toBeVisible({ timeout: 5 * 60 * 1000 });
const newContainerNode = await explorer.waitForContainerNode(context.database.id, newContainerId); // const newContainerNode = await explorer.waitForContainerNode(context.database.id, newContainerId);
expect(newContainerNode).not.toBeNull(); // expect(newContainerNode).not.toBeNull();
// Now try to switch to existing container // // Now try to switch to existing container
// Ensure this job name is different from the previously processed job name // // Ensure this job name is different from the previously processed job name
previousJobName = jobName; // previousJobName = jobName;
await changePartitionKeyButton.click(); // await changePartitionKeyButton.click();
await changePkPanel.getByText("Existing container").click(); // await changePkPanel.getByText("Existing container").click();
await changePkPanel.getByLabel("Use existing container").check(); // await changePkPanel.getByLabel("Use existing container").check();
await changePkPanel.getByText("Choose an existing container").click(); // await changePkPanel.getByText("Choose an existing container").click();
const containerDropdownItem = await explorer.getDropdownItemByName(newContainerId, "Existing Containers"); // const containerDropdownItem = await explorer.getDropdownItemByName(newContainerId, "Existing Containers");
await containerDropdownItem.click(); // await containerDropdownItem.click();
let secondJobName: string | undefined; // let secondJobName: string | undefined;
await Promise.all([ // await Promise.all([
page.waitForRequest( // page.waitForRequest(
(req) => { // (req) => {
const requestUrl = req.url(); // const requestUrl = req.url();
if (requestUrl.includes("/dataTransferJobs") && req.method() === "PUT") { // if (requestUrl.includes("/dataTransferJobs") && req.method() === "PUT") {
secondJobName = new URL(requestUrl).pathname.split("/").pop(); // secondJobName = new URL(requestUrl).pathname.split("/").pop();
return true; // return true;
} // }
return false; // return false;
}, // },
{ timeout: 120000 }, // { timeout: 120000 },
), // ),
changePkPanel.getByTestId("Panel/OkButton").click(), // changePkPanel.getByTestId("Panel/OkButton").click(),
]); // ]);
const cancelButton = explorer.frame.getByRole("button", { name: "Cancel" }); // const cancelButton = explorer.frame.getByRole("button", { name: "Cancel" });
const isCancelButtonVisible = await cancelButton.isVisible().catch(() => false); // const isCancelButtonVisible = await cancelButton.isVisible().catch(() => false);
if (isCancelButtonVisible) { // if (isCancelButtonVisible) {
await cancelButton.click(); // await cancelButton.click();
// Dismiss overlay if it appears // // Dismiss overlay if it appears
const overlayFrame = explorer.frame.locator("#webpack-dev-server-client-overlay").first(); // const overlayFrame = explorer.frame.locator("#webpack-dev-server-client-overlay").first();
if (await overlayFrame.count()) { // if (await overlayFrame.count()) {
await overlayFrame.contentFrame().getByLabel("Dismiss").click(); // await overlayFrame.contentFrame().getByLabel("Dismiss").click();
} // }
const cancelledJobRow = explorer.frame.getByTestId("Tab:tab0"); // const cancelledJobRow = explorer.frame.getByTestId("Tab:tab0");
await expect(cancelledJobRow.getByText("Cancelled")).toBeVisible({ timeout: 30 * 1000 }); // await expect(cancelledJobRow.getByText("Cancelled")).toBeVisible({ timeout: 30 * 1000 });
} else { // } else {
const jobRow = explorer.frame.locator(".ms-ProgressIndicator-itemDescription"); // const jobRow = explorer.frame.locator(".ms-ProgressIndicator-itemDescription");
await expect(jobRow.getByText("Completed")).toBeVisible({ timeout: 5 * 60 * 1000 }); // await expect(jobRow.getByText("Completed")).toBeVisible({ timeout: 5 * 60 * 1000 });
expect(secondJobName).not.toBe(previousJobName); // expect(secondJobName).not.toBe(previousJobName);
} // }
}); // });
}); // });
@@ -1,113 +1,113 @@
import { expect, Page, test } from "@playwright/test"; // import { expect, Page, test } from "@playwright/test";
import * as DataModels from "../../../src/Contracts/DataModels"; // import * as DataModels from "../../../src/Contracts/DataModels";
import { CommandBarButton, DataExplorer, ONE_MINUTE_MS, TestAccount } from "../../fx"; // import { CommandBarButton, DataExplorer, ONE_MINUTE_MS, TestAccount } from "../../fx";
import { createTestSQLContainer, TestContainerContext } from "../../testData"; // import { createTestSQLContainer, TestContainerContext } from "../../testData";
test.describe("Computed Properties", () => { // test.describe("Computed Properties", () => {
let context: TestContainerContext = null!; // let context: TestContainerContext = null!;
let explorer: DataExplorer = null!; // let explorer: DataExplorer = null!;
test.beforeAll("Create Test Database", async () => { // test.beforeAll("Create Test Database", async () => {
context = await createTestSQLContainer(); // context = await createTestSQLContainer();
}); // });
test.beforeEach("Open Settings tab under Scale & Settings", async ({ page }) => { // test.beforeEach("Open Settings tab under Scale & Settings", async ({ page }) => {
explorer = await DataExplorer.open(page, TestAccount.SQL); // explorer = await DataExplorer.open(page, TestAccount.SQL);
const containerNode = await explorer.waitForContainerNode(context.database.id, context.container.id); // const containerNode = await explorer.waitForContainerNode(context.database.id, context.container.id);
await containerNode.expand(); // await containerNode.expand();
// Click Scale & Settings and open Settings tab // // Click Scale & Settings and open Settings tab
await explorer.openScaleAndSettings(context); // await explorer.openScaleAndSettings(context);
const computedPropertiesTab = explorer.frame.getByTestId("settings-tab-header/ComputedPropertiesTab"); // const computedPropertiesTab = explorer.frame.getByTestId("settings-tab-header/ComputedPropertiesTab");
await computedPropertiesTab.click(); // await computedPropertiesTab.click();
}); // });
test.afterAll("Delete Test Database", async () => { // test.afterAll("Delete Test Database", async () => {
if (!process.env.CI) { // if (!process.env.CI) {
await context?.dispose(); // await context?.dispose();
} // }
}); // });
test("Add valid computed property", async ({ page }) => { // test("Add valid computed property", async ({ page }) => {
test.skip(); // test.skip();
await clearComputedPropertiesTextBoxContent({ page }); // await clearComputedPropertiesTextBoxContent({ page });
// Create computed property // // Create computed property
const computedProperties: DataModels.ComputedProperties = [ // const computedProperties: DataModels.ComputedProperties = [
{ // {
name: "cp_lowerName", // name: "cp_lowerName",
query: "SELECT VALUE LOWER(c.name) FROM c", // query: "SELECT VALUE LOWER(c.name) FROM c",
}, // },
]; // ];
const computedPropertiesString: string = JSON.stringify(computedProperties); // const computedPropertiesString: string = JSON.stringify(computedProperties);
await page.keyboard.type(computedPropertiesString); // await page.keyboard.type(computedPropertiesString);
// Save changes // // Save changes
const saveButton = explorer.commandBarButton(CommandBarButton.Save); // const saveButton = explorer.commandBarButton(CommandBarButton.Save);
await expect(saveButton).toBeEnabled(); // await expect(saveButton).toBeEnabled();
await saveButton.click(); // await saveButton.click();
await expect(explorer.getConsoleHeaderStatus()).toContainText( // await expect(explorer.getConsoleHeaderStatus()).toContainText(
`Successfully updated container ${context.container.id}`, // `Successfully updated container ${context.container.id}`,
{ // {
timeout: ONE_MINUTE_MS, // timeout: ONE_MINUTE_MS,
}, // },
); // );
}); // });
test("Add computed property with invalid query", async ({ page }) => { // test("Add computed property with invalid query", async ({ page }) => {
test.skip(); // test.skip();
await clearComputedPropertiesTextBoxContent({ page }); // await clearComputedPropertiesTextBoxContent({ page });
// Create computed property with no VALUE keyword in query // // Create computed property with no VALUE keyword in query
const computedProperties: DataModels.ComputedProperties = [ // const computedProperties: DataModels.ComputedProperties = [
{ // {
name: "cp_lowerName", // name: "cp_lowerName",
query: "SELECT LOWER(c.name) FROM c", // query: "SELECT LOWER(c.name) FROM c",
}, // },
]; // ];
const computedPropertiesString: string = JSON.stringify(computedProperties); // const computedPropertiesString: string = JSON.stringify(computedProperties);
await page.keyboard.type(computedPropertiesString); // await page.keyboard.type(computedPropertiesString);
// Save changes // // Save changes
const saveButton = explorer.commandBarButton(CommandBarButton.Save); // const saveButton = explorer.commandBarButton(CommandBarButton.Save);
await expect(saveButton).toBeEnabled(); // await expect(saveButton).toBeEnabled();
await saveButton.click(); // await saveButton.click();
await expect(explorer.getConsoleHeaderStatus()).toContainText( // await expect(explorer.getConsoleHeaderStatus()).toContainText(
`Failed to update container ${context.container.id}`, // `Failed to update container ${context.container.id}`,
{ // {
timeout: ONE_MINUTE_MS, // timeout: ONE_MINUTE_MS,
}, // },
); // );
}); // });
test("Add computed property with invalid json", async ({ page }) => { // test("Add computed property with invalid json", async ({ page }) => {
test.skip(); // test.skip();
await clearComputedPropertiesTextBoxContent({ page }); // await clearComputedPropertiesTextBoxContent({ page });
// Create computed property with no VALUE keyword in query // // Create computed property with no VALUE keyword in query
const computedProperties: DataModels.ComputedProperties = [ // const computedProperties: DataModels.ComputedProperties = [
{ // {
name: "cp_lowerName", // name: "cp_lowerName",
query: "SELECT LOWER(c.name) FROM c", // query: "SELECT LOWER(c.name) FROM c",
}, // },
]; // ];
const computedPropertiesString: string = JSON.stringify(computedProperties); // const computedPropertiesString: string = JSON.stringify(computedProperties);
await page.keyboard.type(computedPropertiesString + "]"); // await page.keyboard.type(computedPropertiesString + "]");
// Save button should remain disabled due to invalid json // // Save button should remain disabled due to invalid json
const saveButton = explorer.commandBarButton(CommandBarButton.Save); // const saveButton = explorer.commandBarButton(CommandBarButton.Save);
await expect(saveButton).toBeDisabled(); // await expect(saveButton).toBeDisabled();
}); // });
const clearComputedPropertiesTextBoxContent = async ({ page }: { page: Page }): Promise<void> => { // const clearComputedPropertiesTextBoxContent = async ({ page }: { page: Page }): Promise<void> => {
// Get computed properties text box // // Get computed properties text box
await explorer.frame.waitForSelector(".monaco-scrollable-element", { state: "visible" }); // await explorer.frame.waitForSelector(".monaco-scrollable-element", { state: "visible" });
const computedPropertiesEditor = explorer.frame.getByTestId("computed-properties-editor"); // const computedPropertiesEditor = explorer.frame.getByTestId("computed-properties-editor");
await computedPropertiesEditor.click(); // await computedPropertiesEditor.click();
// Clear existing content (Ctrl+A + Backspace does not work with webkit) // // Clear existing content (Ctrl+A + Backspace does not work with webkit)
for (let i = 0; i < 100; i++) { // for (let i = 0; i < 100; i++) {
await page.keyboard.press("Backspace"); // await page.keyboard.press("Backspace");
} // }
}; // };
}); // });
@@ -1,198 +1,198 @@
import { expect, test } from "@playwright/test"; // import { expect, test } from "@playwright/test";
import { CommandBarButton, DataExplorer, ONE_MINUTE_MS, TestAccount } from "../../../fx"; // import { CommandBarButton, DataExplorer, ONE_MINUTE_MS, TestAccount } from "../../../fx";
import { createTestSQLContainer, TestContainerContext } from "../../../testData"; // import { createTestSQLContainer, TestContainerContext } from "../../../testData";
test.describe("Vector Policy under Scale & Settings", () => { // test.describe("Vector Policy under Scale & Settings", () => {
let context: TestContainerContext = null!; // let context: TestContainerContext = null!;
let explorer: DataExplorer = null!; // let explorer: DataExplorer = null!;
test.beforeAll("Create Test Database", async () => { // test.beforeAll("Create Test Database", async () => {
context = await createTestSQLContainer(); // context = await createTestSQLContainer();
}); // });
test.beforeEach("Open Container Policy tab under Scale & Settings", async ({ page }) => { // test.beforeEach("Open Container Policy tab under Scale & Settings", async ({ page }) => {
explorer = await DataExplorer.open(page, TestAccount.SQL); // explorer = await DataExplorer.open(page, TestAccount.SQL);
await explorer.waitForContainerNode(context.database.id, context.container.id); // await explorer.waitForContainerNode(context.database.id, context.container.id);
// Click Scale & Settings and open Container Policy tab // // Click Scale & Settings and open Container Policy tab
await explorer.openScaleAndSettings(context); // await explorer.openScaleAndSettings(context);
const containerPolicyTab = explorer.frame.getByTestId("settings-tab-header/ContainerVectorPolicyTab"); // const containerPolicyTab = explorer.frame.getByTestId("settings-tab-header/ContainerVectorPolicyTab");
await containerPolicyTab.click(); // await containerPolicyTab.click();
// Click on Vector Policy tab // // Click on Vector Policy tab
const vectorPolicyTab = explorer.frame.getByRole("tab", { name: "Vector Policy" }); // const vectorPolicyTab = explorer.frame.getByRole("tab", { name: "Vector Policy" });
await vectorPolicyTab.click(); // await vectorPolicyTab.click();
}); // });
test.afterEach("Clear vector policies", async () => { // test.afterEach("Clear vector policies", async () => {
const { resource: containerDef } = await context.container.read(); // const { resource: containerDef } = await context.container.read();
if (containerDef.vectorEmbeddingPolicy?.vectorEmbeddings?.length) { // if (containerDef.vectorEmbeddingPolicy?.vectorEmbeddings?.length) {
containerDef.vectorEmbeddingPolicy.vectorEmbeddings = []; // containerDef.vectorEmbeddingPolicy.vectorEmbeddings = [];
await context.container.replace(containerDef); // await context.container.replace(containerDef);
} // }
}); // });
test.afterAll("Delete Test Database", async () => { // test.afterAll("Delete Test Database", async () => {
await context?.dispose(); // await context?.dispose();
}); // });
/** Count vector policy entries currently in the DOM. */ // /** Count vector policy entries currently in the DOM. */
const getPolicyCount = async (): Promise<number> => { // const getPolicyCount = async (): Promise<number> => {
for (let i = 1; i <= 20; i++) { // for (let i = 1; i <= 20; i++) {
if ((await explorer.frame.locator(`#vector-policy-path-${i}`).count()) === 0) { // if ((await explorer.frame.locator(`#vector-policy-path-${i}`).count()) === 0) {
return i - 1; // return i - 1;
} // }
} // }
return 20; // return 20;
}; // };
/** // /**
* Ensure at least one saved (existing) vector policy exists on the container. // * Ensure at least one saved (existing) vector policy exists on the container.
* If none exist, add one and save it. Returns the total policy count afterward. // * If none exist, add one and save it. Returns the total policy count afterward.
*/ // */
const ensureExistingPolicy = async (): Promise<number> => { // const ensureExistingPolicy = async (): Promise<number> => {
const count = await getPolicyCount(); // const count = await getPolicyCount();
if (count > 0) { // if (count > 0) {
return count; // return count;
} // }
// No saved policies — add and save one // // No saved policies — add and save one
const addButton = explorer.frame.locator("#add-vector-policy"); // const addButton = explorer.frame.locator("#add-vector-policy");
await addButton.click(); // await addButton.click();
await explorer.frame.locator("#vector-policy-path-1").fill("/existingPolicy"); // await explorer.frame.locator("#vector-policy-path-1").fill("/existingPolicy");
await explorer.frame.locator("#vector-policy-dimension-1").fill("500"); // await explorer.frame.locator("#vector-policy-dimension-1").fill("500");
const saveButton = explorer.commandBarButton(CommandBarButton.Save); // const saveButton = explorer.commandBarButton(CommandBarButton.Save);
await saveButton.click(); // await saveButton.click();
await expect(explorer.getConsoleHeaderStatus()).toContainText( // await expect(explorer.getConsoleHeaderStatus()).toContainText(
`Successfully updated container ${context.container.id}`, // `Successfully updated container ${context.container.id}`,
{ timeout: 2 * ONE_MINUTE_MS }, // { timeout: 2 * ONE_MINUTE_MS },
); // );
return 1; // return 1;
}; // };
test("Add new vector embedding policy", async () => { // test("Add new vector embedding policy", async () => {
test.skip(); // test.skip();
const existingCount = await getPolicyCount(); // const existingCount = await getPolicyCount();
// Click Add vector embedding button // // Click Add vector embedding button
const addButton = explorer.frame.locator("#add-vector-policy"); // const addButton = explorer.frame.locator("#add-vector-policy");
await addButton.click(); // await addButton.click();
const newIndex = existingCount + 1; // const newIndex = existingCount + 1;
// Fill in path // // Fill in path
const pathInput = explorer.frame.locator(`#vector-policy-path-${newIndex}`); // const pathInput = explorer.frame.locator(`#vector-policy-path-${newIndex}`);
await pathInput.fill("/embedding"); // await pathInput.fill("/embedding");
// Fill in dimensions // // Fill in dimensions
const dimensionsInput = explorer.frame.locator(`#vector-policy-dimension-${newIndex}`); // const dimensionsInput = explorer.frame.locator(`#vector-policy-dimension-${newIndex}`);
await dimensionsInput.fill("1500"); // await dimensionsInput.fill("1500");
// Save changes // // Save changes
const saveButton = explorer.commandBarButton(CommandBarButton.Save); // const saveButton = explorer.commandBarButton(CommandBarButton.Save);
await expect(saveButton).toBeEnabled(); // await expect(saveButton).toBeEnabled();
await saveButton.click(); // await saveButton.click();
await expect(explorer.getConsoleHeaderStatus()).toContainText( // await expect(explorer.getConsoleHeaderStatus()).toContainText(
`Successfully updated container ${context.container.id}`, // `Successfully updated container ${context.container.id}`,
{ // {
timeout: 2 * ONE_MINUTE_MS, // timeout: 2 * ONE_MINUTE_MS,
}, // },
); // );
}); // });
test("Existing vector embedding policy fields are disabled", async () => { // test("Existing vector embedding policy fields are disabled", async () => {
test.skip(); // test.skip();
// Ensure there is at least one saved policy // // Ensure there is at least one saved policy
await ensureExistingPolicy(); // await ensureExistingPolicy();
// Verify the path field is disabled for the existing policy // // Verify the path field is disabled for the existing policy
const existingPathInput = explorer.frame.locator("#vector-policy-path-1"); // const existingPathInput = explorer.frame.locator("#vector-policy-path-1");
await expect(existingPathInput).toBeDisabled(); // await expect(existingPathInput).toBeDisabled();
// Verify the dimensions field is disabled for the existing policy // // Verify the dimensions field is disabled for the existing policy
const existingDimensionsInput = explorer.frame.locator("#vector-policy-dimension-1"); // const existingDimensionsInput = explorer.frame.locator("#vector-policy-dimension-1");
await expect(existingDimensionsInput).toBeDisabled(); // await expect(existingDimensionsInput).toBeDisabled();
}); // });
test("New vector embedding policy fields are enabled while existing are disabled", async () => { // test("New vector embedding policy fields are enabled while existing are disabled", async () => {
test.skip(); // test.skip();
// Ensure there is at least one saved policy // // Ensure there is at least one saved policy
const existingCount = await ensureExistingPolicy(); // const existingCount = await ensureExistingPolicy();
// Now add a new policy // // Now add a new policy
const addButton = explorer.frame.locator("#add-vector-policy"); // const addButton = explorer.frame.locator("#add-vector-policy");
await addButton.click(); // await addButton.click();
const newIndex = existingCount + 1; // const newIndex = existingCount + 1;
// Verify the existing policy fields are disabled // // Verify the existing policy fields are disabled
const existingPathInput = explorer.frame.locator("#vector-policy-path-1"); // const existingPathInput = explorer.frame.locator("#vector-policy-path-1");
const existingDimensionsInput = explorer.frame.locator("#vector-policy-dimension-1"); // const existingDimensionsInput = explorer.frame.locator("#vector-policy-dimension-1");
await expect(existingPathInput).toBeDisabled(); // await expect(existingPathInput).toBeDisabled();
await expect(existingDimensionsInput).toBeDisabled(); // await expect(existingDimensionsInput).toBeDisabled();
// Verify the new policy fields are enabled // // Verify the new policy fields are enabled
const newPathInput = explorer.frame.locator(`#vector-policy-path-${newIndex}`); // const newPathInput = explorer.frame.locator(`#vector-policy-path-${newIndex}`);
const newDimensionsInput = explorer.frame.locator(`#vector-policy-dimension-${newIndex}`); // const newDimensionsInput = explorer.frame.locator(`#vector-policy-dimension-${newIndex}`);
await expect(newPathInput).toBeEnabled(); // await expect(newPathInput).toBeEnabled();
await expect(newDimensionsInput).toBeEnabled(); // await expect(newDimensionsInput).toBeEnabled();
}); // });
test("Delete existing vector embedding policy", async () => { // test("Delete existing vector embedding policy", async () => {
test.skip(); // test.skip();
// Ensure there is at least one saved policy to delete // // Ensure there is at least one saved policy to delete
const existingCount = await ensureExistingPolicy(); // const existingCount = await ensureExistingPolicy();
// Verify the policy exists // // Verify the policy exists
const pathInput = explorer.frame.locator("#vector-policy-path-1"); // const pathInput = explorer.frame.locator("#vector-policy-path-1");
await expect(pathInput).toBeVisible(); // await expect(pathInput).toBeVisible();
// Click the delete (trash) button for the first vector embedding // // Click the delete (trash) button for the first vector embedding
const deleteButton = explorer.frame.locator("#delete-Vector-embedding-1"); // const deleteButton = explorer.frame.locator("#delete-Vector-embedding-1");
await expect(deleteButton).toBeEnabled(); // await expect(deleteButton).toBeEnabled();
await deleteButton.click(); // await deleteButton.click();
// Verify one fewer policy entry in the UI // // Verify one fewer policy entry in the UI
const countAfterDelete = await getPolicyCount(); // const countAfterDelete = await getPolicyCount();
expect(countAfterDelete).toBe(existingCount - 1); // expect(countAfterDelete).toBe(existingCount - 1);
// Save the deletion // // Save the deletion
const saveButton = explorer.commandBarButton(CommandBarButton.Save); // const saveButton = explorer.commandBarButton(CommandBarButton.Save);
await expect(saveButton).toBeEnabled(); // await expect(saveButton).toBeEnabled();
await saveButton.click(); // await saveButton.click();
await expect(explorer.getConsoleHeaderStatus()).toContainText( // await expect(explorer.getConsoleHeaderStatus()).toContainText(
`Successfully updated container ${context.container.id}`, // `Successfully updated container ${context.container.id}`,
{ // {
timeout: 2 * ONE_MINUTE_MS, // timeout: 2 * ONE_MINUTE_MS,
}, // },
); // );
// Verify the count is still reduced after save // // Verify the count is still reduced after save
const countAfterSave = await getPolicyCount(); // const countAfterSave = await getPolicyCount();
expect(countAfterSave).toBe(existingCount - 1); // expect(countAfterSave).toBe(existingCount - 1);
}); // });
test("Validation error for empty path", async () => { // test("Validation error for empty path", async () => {
test.skip(); // test.skip();
const existingCount = await getPolicyCount(); // const existingCount = await getPolicyCount();
const addButton = explorer.frame.locator("#add-vector-policy"); // const addButton = explorer.frame.locator("#add-vector-policy");
await addButton.click(); // await addButton.click();
const newIndex = existingCount + 1; // const newIndex = existingCount + 1;
// Leave path empty, just fill dimensions // // Leave path empty, just fill dimensions
const dimensionsInput = explorer.frame.locator(`#vector-policy-dimension-${newIndex}`); // const dimensionsInput = explorer.frame.locator(`#vector-policy-dimension-${newIndex}`);
await dimensionsInput.fill("512"); // await dimensionsInput.fill("512");
// Check for validation error on path // // Check for validation error on path
const pathError = explorer.frame.locator("text=Path should not be empty"); // const pathError = explorer.frame.locator("text=Path should not be empty");
await expect(pathError).toBeVisible(); // await expect(pathError).toBeVisible();
// Verify save button is disabled due to validation error // // Verify save button is disabled due to validation error
const saveButton = explorer.commandBarButton(CommandBarButton.Save); // const saveButton = explorer.commandBarButton(CommandBarButton.Save);
await expect(saveButton).toBeDisabled(); // await expect(saveButton).toBeDisabled();
}); // });
}); // });
+105 -105
View File
@@ -1,129 +1,129 @@
import { expect, test, type Page } from "@playwright/test"; // import { expect, test, type Page } from "@playwright/test";
import { DataExplorer, TestAccount } from "../../fx"; // import { DataExplorer, TestAccount } from "../../fx";
import { createTestSQLContainer, TestContainerContext } from "../../testData"; // import { createTestSQLContainer, TestContainerContext } from "../../testData";
/** // /**
* Tests for Dynamic Data Masking (DDM) feature. // * Tests for Dynamic Data Masking (DDM) feature.
* // *
* Prerequisites: // * Prerequisites:
* - Test account must have the EnableDynamicDataMasking capability enabled // * - Test account must have the EnableDynamicDataMasking capability enabled
* - If the capability is not enabled, the DataMaskingTab will not be visible and tests will be skipped // * - If the capability is not enabled, the DataMaskingTab will not be visible and tests will be skipped
* // *
* Important Notes: // * Important Notes:
* - Tests focus on enabling DDM and modifying the masking policy configuration // * - Tests focus on enabling DDM and modifying the masking policy configuration
*/ // */
let testContainer: TestContainerContext; // let testContainer: TestContainerContext;
let DATABASE_ID: string; // let DATABASE_ID: string;
let CONTAINER_ID: string; // let CONTAINER_ID: string;
test.beforeAll(async () => { // test.beforeAll(async () => {
testContainer = await createTestSQLContainer(); // testContainer = await createTestSQLContainer();
DATABASE_ID = testContainer.database.id; // DATABASE_ID = testContainer.database.id;
CONTAINER_ID = testContainer.container.id; // CONTAINER_ID = testContainer.container.id;
}); // });
// Clean up test database after all tests // // Clean up test database after all tests
test.afterAll(async () => { // test.afterAll(async () => {
if (testContainer) { // if (testContainer) {
await testContainer.dispose(); // await testContainer.dispose();
} // }
}); // });
// Helper function to navigate to Data Masking tab // // Helper function to navigate to Data Masking tab
async function navigateToDataMaskingTab(page: Page, explorer: DataExplorer): Promise<boolean> { // async function navigateToDataMaskingTab(page: Page, explorer: DataExplorer): Promise<boolean> {
// Refresh the tree to see the newly created database // // Refresh the tree to see the newly created database
const refreshButton = explorer.frame.getByTestId("Sidebar/RefreshButton"); // const refreshButton = explorer.frame.getByTestId("Sidebar/RefreshButton");
await refreshButton.click(); // await refreshButton.click();
await page.waitForTimeout(3000); // await page.waitForTimeout(3000);
// Expand database and container nodes // // Expand database and container nodes
const databaseNode = await explorer.waitForNode(DATABASE_ID); // const databaseNode = await explorer.waitForNode(DATABASE_ID);
await databaseNode.expand(); // await databaseNode.expand();
await page.waitForTimeout(2000); // await page.waitForTimeout(2000);
const containerNode = await explorer.waitForNode(`${DATABASE_ID}/${CONTAINER_ID}`); // const containerNode = await explorer.waitForNode(`${DATABASE_ID}/${CONTAINER_ID}`);
await containerNode.expand(); // await containerNode.expand();
await page.waitForTimeout(1000); // await page.waitForTimeout(1000);
// Click Scale & Settings or Settings (depending on container type) // // Click Scale & Settings or Settings (depending on container type)
let settingsNode = explorer.frame.getByTestId(`TreeNode:${DATABASE_ID}/${CONTAINER_ID}/Scale & Settings`); // let settingsNode = explorer.frame.getByTestId(`TreeNode:${DATABASE_ID}/${CONTAINER_ID}/Scale & Settings`);
const isScaleAndSettings = await settingsNode.isVisible().catch(() => false); // const isScaleAndSettings = await settingsNode.isVisible().catch(() => false);
if (!isScaleAndSettings) { // if (!isScaleAndSettings) {
settingsNode = explorer.frame.getByTestId(`TreeNode:${DATABASE_ID}/${CONTAINER_ID}/Settings`); // settingsNode = explorer.frame.getByTestId(`TreeNode:${DATABASE_ID}/${CONTAINER_ID}/Settings`);
} // }
await settingsNode.click(); // await settingsNode.click();
await page.waitForTimeout(2000); // await page.waitForTimeout(2000);
// Check if Data Masking tab is available // // Check if Data Masking tab is available
const dataMaskingTab = explorer.frame.getByTestId("settings-tab-header/DataMaskingTab"); // const dataMaskingTab = explorer.frame.getByTestId("settings-tab-header/DataMaskingTab");
const isTabVisible = await dataMaskingTab.isVisible().catch(() => false); // const isTabVisible = await dataMaskingTab.isVisible().catch(() => false);
if (!isTabVisible) { // if (!isTabVisible) {
return false; // return false;
} // }
await dataMaskingTab.click(); // await dataMaskingTab.click();
await page.waitForTimeout(1000); // await page.waitForTimeout(1000);
return true; // return true;
} // }
test.describe("Data Masking under Scale & Settings", () => { // test.describe("Data Masking under Scale & Settings", () => {
test("Data Masking tab should be visible and show JSON editor", async ({ page }) => { // test("Data Masking tab should be visible and show JSON editor", async ({ page }) => {
const explorer = await DataExplorer.open(page, TestAccount.SQL); // const explorer = await DataExplorer.open(page, TestAccount.SQL);
const isTabAvailable = await navigateToDataMaskingTab(page, explorer); // const isTabAvailable = await navigateToDataMaskingTab(page, explorer);
if (!isTabAvailable) { // if (!isTabAvailable) {
test.skip( // test.skip(
true, // true,
"Data Masking tab is not available. Test account may not have EnableDynamicDataMasking capability.", // "Data Masking tab is not available. Test account may not have EnableDynamicDataMasking capability.",
); // );
} // }
// Verify the Data Masking editor is visible // // Verify the Data Masking editor is visible
const dataMaskingEditor = explorer.frame.locator(".settingsV2Editor"); // const dataMaskingEditor = explorer.frame.locator(".settingsV2Editor");
await expect(dataMaskingEditor).toBeVisible(); // await expect(dataMaskingEditor).toBeVisible();
}); // });
test("Data Masking editor should contain default policy structure", async ({ page }) => { // test("Data Masking editor should contain default policy structure", async ({ page }) => {
test.skip(); // test.skip();
const explorer = await DataExplorer.open(page, TestAccount.SQL); // const explorer = await DataExplorer.open(page, TestAccount.SQL);
const isTabAvailable = await navigateToDataMaskingTab(page, explorer); // const isTabAvailable = await navigateToDataMaskingTab(page, explorer);
if (!isTabAvailable) { // if (!isTabAvailable) {
test.skip( // test.skip(
true, // true,
"Data Masking tab is not available. Test account may not have EnableDynamicDataMasking capability.", // "Data Masking tab is not available. Test account may not have EnableDynamicDataMasking capability.",
); // );
} // }
// Verify the editor contains the expected JSON structure fields // // Verify the editor contains the expected JSON structure fields
const editorContent = explorer.frame.locator(".settingsV2Editor"); // const editorContent = explorer.frame.locator(".settingsV2Editor");
await expect(editorContent).toBeVisible(); // await expect(editorContent).toBeVisible();
// Check that the editor contains key policy fields (default policy has empty arrays) // // Check that the editor contains key policy fields (default policy has empty arrays)
await expect(editorContent).toContainText("includedPaths"); // await expect(editorContent).toContainText("includedPaths");
await expect(editorContent).toContainText("excludedPaths"); // await expect(editorContent).toContainText("excludedPaths");
}); // });
test("Data Masking editor should have correct default policy values", async ({ page }) => { // test("Data Masking editor should have correct default policy values", async ({ page }) => {
test.skip(); // test.skip();
const explorer = await DataExplorer.open(page, TestAccount.SQL); // const explorer = await DataExplorer.open(page, TestAccount.SQL);
const isTabAvailable = await navigateToDataMaskingTab(page, explorer); // const isTabAvailable = await navigateToDataMaskingTab(page, explorer);
if (!isTabAvailable) { // if (!isTabAvailable) {
test.skip( // test.skip(
true, // true,
"Data Masking tab is not available. Test account may not have EnableDynamicDataMasking capability.", // "Data Masking tab is not available. Test account may not have EnableDynamicDataMasking capability.",
); // );
} // }
const editorContent = explorer.frame.locator(".settingsV2Editor"); // const editorContent = explorer.frame.locator(".settingsV2Editor");
await expect(editorContent).toBeVisible(); // await expect(editorContent).toBeVisible();
// Default policy should have empty includedPaths and excludedPaths arrays // // Default policy should have empty includedPaths and excludedPaths arrays
await expect(editorContent).toContainText("[]"); // await expect(editorContent).toContainText("[]");
}); // });
}); // });
+104 -104
View File
@@ -1,127 +1,127 @@
import { Browser, expect, Locator, Page, test } from "@playwright/test"; // import { Browser, expect, Locator, Page, test } from "@playwright/test";
import { // import {
CommandBarButton, // CommandBarButton,
DataExplorer, // DataExplorer,
ONE_MINUTE_MS, // ONE_MINUTE_MS,
TEST_AUTOSCALE_MAX_THROUGHPUT_RU_2K, // TEST_AUTOSCALE_MAX_THROUGHPUT_RU_2K,
TEST_MANUAL_THROUGHPUT_RU_2K, // TEST_MANUAL_THROUGHPUT_RU_2K,
TestAccount, // TestAccount,
} from "../../fx"; // } from "../../fx";
import { createTestSQLContainer, TestContainerContext } from "../../testData"; // import { createTestSQLContainer, TestContainerContext } from "../../testData";
interface SetupResult { // interface SetupResult {
context: TestContainerContext; // context: TestContainerContext;
page: Page; // page: Page;
explorer: DataExplorer; // explorer: DataExplorer;
} // }
test.describe("Autoscale throughput", () => { // test.describe("Autoscale throughput", () => {
let setup: SetupResult; // let setup: SetupResult;
test.beforeAll(async ({ browser }) => { // test.beforeAll(async ({ browser }) => {
setup = await openScaleTab(browser); // setup = await openScaleTab(browser);
// Switch manual -> autoscale once for this suite // // Switch manual -> autoscale once for this suite
const autoscaleRadioButton = setup.explorer.frame.getByText("Autoscale", { exact: true }); // const autoscaleRadioButton = setup.explorer.frame.getByText("Autoscale", { exact: true });
await autoscaleRadioButton.click(); // await autoscaleRadioButton.click();
await expect(setup.explorer.commandBarButton(CommandBarButton.Save)).toBeEnabled(); // await expect(setup.explorer.commandBarButton(CommandBarButton.Save)).toBeEnabled();
await setup.explorer.commandBarButton(CommandBarButton.Save).click(); // await setup.explorer.commandBarButton(CommandBarButton.Save).click();
await expect(setup.explorer.getConsoleHeaderStatus()).toContainText( // await expect(setup.explorer.getConsoleHeaderStatus()).toContainText(
`Successfully updated offer for collection ${setup.context.container.id}`, // `Successfully updated offer for collection ${setup.context.container.id}`,
{ timeout: 2 * ONE_MINUTE_MS }, // { timeout: 2 * ONE_MINUTE_MS },
); // );
}); // });
test.afterAll(async () => { // test.afterAll(async () => {
await cleanup(setup); // await cleanup(setup);
}); // });
test("Update autoscale max throughput", async () => { // test("Update autoscale max throughput", async () => {
test.skip(); // test.skip();
await getThroughputInput(setup.explorer, "autopilot").fill(TEST_AUTOSCALE_MAX_THROUGHPUT_RU_2K.toString()); // await getThroughputInput(setup.explorer, "autopilot").fill(TEST_AUTOSCALE_MAX_THROUGHPUT_RU_2K.toString());
await setup.explorer.commandBarButton(CommandBarButton.Save).click(); // await setup.explorer.commandBarButton(CommandBarButton.Save).click();
await expect(setup.explorer.getConsoleHeaderStatus()).toContainText( // await expect(setup.explorer.getConsoleHeaderStatus()).toContainText(
`Successfully updated offer for collection ${setup.context.container.id}`, // `Successfully updated offer for collection ${setup.context.container.id}`,
{ timeout: 2 * ONE_MINUTE_MS }, // { timeout: 2 * ONE_MINUTE_MS },
); // );
}); // });
test("Update autoscale max throughput passed allowed limit", async () => { // test("Update autoscale max throughput passed allowed limit", async () => {
test.skip(); // test.skip();
const softAllowedMaxThroughputString = await setup.explorer.frame // const softAllowedMaxThroughputString = await setup.explorer.frame
.getByTestId("soft-allowed-maximum-throughput") // .getByTestId("soft-allowed-maximum-throughput")
.innerText(); // .innerText();
const softAllowedMaxThroughput = Number(softAllowedMaxThroughputString.replace(/,/g, "")); // const softAllowedMaxThroughput = Number(softAllowedMaxThroughputString.replace(/,/g, ""));
await getThroughputInput(setup.explorer, "autopilot").fill((softAllowedMaxThroughput * 10).toString()); // await getThroughputInput(setup.explorer, "autopilot").fill((softAllowedMaxThroughput * 10).toString());
await expect(setup.explorer.commandBarButton(CommandBarButton.Save)).toBeDisabled(); // await expect(setup.explorer.commandBarButton(CommandBarButton.Save)).toBeDisabled();
await expect(delayedApplyWarning(setup.explorer)).toBeVisible(); // await expect(delayedApplyWarning(setup.explorer)).toBeVisible();
}); // });
test("Update autoscale max throughput with invalid increment", async () => { // test("Update autoscale max throughput with invalid increment", async () => {
test.skip(); // test.skip();
await getThroughputInput(setup.explorer, "autopilot").fill("1100"); // await getThroughputInput(setup.explorer, "autopilot").fill("1100");
await expect(setup.explorer.commandBarButton(CommandBarButton.Save)).toBeDisabled(); // await expect(setup.explorer.commandBarButton(CommandBarButton.Save)).toBeDisabled();
await expect(getThroughputInputErrorMessage(setup.explorer, "autopilot")).toContainText( // await expect(getThroughputInputErrorMessage(setup.explorer, "autopilot")).toContainText(
"Throughput value must be in increments of 1000", // "Throughput value must be in increments of 1000",
); // );
}); // });
}); // });
test.describe("Manual throughput", () => { // test.describe("Manual throughput", () => {
let setup: SetupResult; // let setup: SetupResult;
test.beforeAll(async ({ browser }) => { // test.beforeAll(async ({ browser }) => {
setup = await openScaleTab(browser); // setup = await openScaleTab(browser);
}); // });
test.afterAll(async () => { // test.afterAll(async () => {
await cleanup(setup); // await cleanup(setup);
}); // });
test("Update manual throughput", async () => { // test("Update manual throughput", async () => {
test.skip(); // test.skip();
await getThroughputInput(setup.explorer, "manual").fill(TEST_MANUAL_THROUGHPUT_RU_2K.toString()); // await getThroughputInput(setup.explorer, "manual").fill(TEST_MANUAL_THROUGHPUT_RU_2K.toString());
await setup.explorer.commandBarButton(CommandBarButton.Save).click(); // await setup.explorer.commandBarButton(CommandBarButton.Save).click();
await expect(setup.explorer.getConsoleHeaderStatus()).toContainText( // await expect(setup.explorer.getConsoleHeaderStatus()).toContainText(
`Successfully updated offer for collection ${setup.context.container.id}`, // `Successfully updated offer for collection ${setup.context.container.id}`,
{ timeout: 2 * ONE_MINUTE_MS }, // { timeout: 2 * ONE_MINUTE_MS },
); // );
}); // });
test("Update manual throughput passed allowed limit", async () => { // test("Update manual throughput passed allowed limit", async () => {
test.skip(); // test.skip();
const softAllowedMaxThroughputString = await setup.explorer.frame // const softAllowedMaxThroughputString = await setup.explorer.frame
.getByTestId("soft-allowed-maximum-throughput") // .getByTestId("soft-allowed-maximum-throughput")
.innerText(); // .innerText();
const softAllowedMaxThroughput = Number(softAllowedMaxThroughputString.replace(/,/g, "")); // const softAllowedMaxThroughput = Number(softAllowedMaxThroughputString.replace(/,/g, ""));
await getThroughputInput(setup.explorer, "manual").fill((softAllowedMaxThroughput * 10).toString()); // await getThroughputInput(setup.explorer, "manual").fill((softAllowedMaxThroughput * 10).toString());
await expect(delayedApplyWarning(setup.explorer)).toBeVisible(); // await expect(delayedApplyWarning(setup.explorer)).toBeVisible();
}); // });
}); // });
const delayedApplyWarning = (explorer: DataExplorer): Locator => // const delayedApplyWarning = (explorer: DataExplorer): Locator =>
explorer.frame.locator("#updateThroughputDelayedApplyWarningMessage"); // explorer.frame.locator("#updateThroughputDelayedApplyWarningMessage");
const getThroughputInput = (explorer: DataExplorer, type: "manual" | "autopilot"): Locator => // const getThroughputInput = (explorer: DataExplorer, type: "manual" | "autopilot"): Locator =>
explorer.frame.getByTestId(`${type}-throughput-input`); // explorer.frame.getByTestId(`${type}-throughput-input`);
const getThroughputInputErrorMessage = (explorer: DataExplorer, type: "manual" | "autopilot"): Locator => // const getThroughputInputErrorMessage = (explorer: DataExplorer, type: "manual" | "autopilot"): Locator =>
explorer.frame.getByTestId(`${type}-throughput-input-error`); // explorer.frame.getByTestId(`${type}-throughput-input-error`);
async function openScaleTab(browser: Browser): Promise<SetupResult> { // async function openScaleTab(browser: Browser): Promise<SetupResult> {
const context = await createTestSQLContainer(); // const context = await createTestSQLContainer();
const page = await browser.newPage(); // const page = await browser.newPage();
const explorer = await DataExplorer.open(page, TestAccount.SQL); // const explorer = await DataExplorer.open(page, TestAccount.SQL);
await explorer.openScaleAndSettings(context); // await explorer.openScaleAndSettings(context);
await explorer.frame.getByTestId("settings-tab-header/ScaleTab").click(); // await explorer.frame.getByTestId("settings-tab-header/ScaleTab").click();
return { context, page, explorer }; // return { context, page, explorer };
} // }
async function cleanup({ context }: Partial<SetupResult>) { // async function cleanup({ context }: Partial<SetupResult>) {
await context?.dispose(); // await context?.dispose();
} // }
+67 -67
View File
@@ -1,80 +1,80 @@
import { expect, test } from "@playwright/test"; // import { expect, test } from "@playwright/test";
import { CommandBarButton, DataExplorer, ONE_MINUTE_MS, TestAccount } from "../../fx"; // import { CommandBarButton, DataExplorer, ONE_MINUTE_MS, TestAccount } from "../../fx";
import { createTestSQLContainer, TestContainerContext } from "../../testData"; // import { createTestSQLContainer, TestContainerContext } from "../../testData";
test.describe("Settings under Scale & Settings", () => { // test.describe("Settings under Scale & Settings", () => {
let context: TestContainerContext = null!; // let context: TestContainerContext = null!;
let explorer: DataExplorer = null!; // let explorer: DataExplorer = null!;
test.beforeAll("Create Test Database & Open Settings tab", async ({ browser }) => { // test.beforeAll("Create Test Database & Open Settings tab", async ({ browser }) => {
context = await createTestSQLContainer(); // context = await createTestSQLContainer();
const page = await browser.newPage(); // const page = await browser.newPage();
explorer = await DataExplorer.open(page, TestAccount.SQL); // explorer = await DataExplorer.open(page, TestAccount.SQL);
// Click Scale & Settings and open Settings tab // // Click Scale & Settings and open Settings tab
await explorer.openScaleAndSettings(context); // await explorer.openScaleAndSettings(context);
const settingsTab = explorer.frame.getByTestId("settings-tab-header/SubSettingsTab"); // const settingsTab = explorer.frame.getByTestId("settings-tab-header/SubSettingsTab");
await settingsTab.click(); // await settingsTab.click();
}); // });
test.afterAll("Delete Test Database", async () => { // test.afterAll("Delete Test Database", async () => {
await context?.dispose(); // await context?.dispose();
}); // });
test("Update TTL to On (no default)", async () => { // test("Update TTL to On (no default)", async () => {
test.skip(); // test.skip();
const ttlOnNoDefaultRadioButton = explorer.frame.getByRole("radio", { name: "ttl-on-no-default-option" }); // const ttlOnNoDefaultRadioButton = explorer.frame.getByRole("radio", { name: "ttl-on-no-default-option" });
await ttlOnNoDefaultRadioButton.click(); // await ttlOnNoDefaultRadioButton.click();
await explorer.commandBarButton(CommandBarButton.Save).click(); // await explorer.commandBarButton(CommandBarButton.Save).click();
await expect(explorer.getConsoleHeaderStatus()).toContainText( // await expect(explorer.getConsoleHeaderStatus()).toContainText(
`Successfully updated container ${context.container.id}`, // `Successfully updated container ${context.container.id}`,
{ // {
timeout: 2 * ONE_MINUTE_MS, // timeout: 2 * ONE_MINUTE_MS,
}, // },
); // );
}); // });
test("Update TTL to On (with user entry)", async () => { // test("Update TTL to On (with user entry)", async () => {
test.skip(); // test.skip();
const ttlOnRadioButton = explorer.frame.getByRole("radio", { name: "ttl-on-option" }); // const ttlOnRadioButton = explorer.frame.getByRole("radio", { name: "ttl-on-option" });
await ttlOnRadioButton.click(); // await ttlOnRadioButton.click();
// Enter TTL seconds // // Enter TTL seconds
const ttlInput = explorer.frame.getByTestId("ttl-input"); // const ttlInput = explorer.frame.getByTestId("ttl-input");
await ttlInput.fill("30000"); // await ttlInput.fill("30000");
await explorer.commandBarButton(CommandBarButton.Save).click(); // await explorer.commandBarButton(CommandBarButton.Save).click();
await expect(explorer.getConsoleHeaderStatus()).toContainText( // await expect(explorer.getConsoleHeaderStatus()).toContainText(
`Successfully updated container ${context.container.id}`, // `Successfully updated container ${context.container.id}`,
{ // {
timeout: 2 * ONE_MINUTE_MS, // timeout: 2 * ONE_MINUTE_MS,
}, // },
); // );
}); // });
test("Set Geospatial Config to Geometry then Geography", async () => { // test("Set Geospatial Config to Geometry then Geography", async () => {
test.skip(); // test.skip();
const geometryRadioButton = explorer.frame.getByRole("radio", { name: "geometry-option" }); // const geometryRadioButton = explorer.frame.getByRole("radio", { name: "geometry-option" });
await geometryRadioButton.click(); // await geometryRadioButton.click();
await explorer.commandBarButton(CommandBarButton.Save).click(); // await explorer.commandBarButton(CommandBarButton.Save).click();
await expect(explorer.getConsoleHeaderStatus()).toContainText( // await expect(explorer.getConsoleHeaderStatus()).toContainText(
`Successfully updated container ${context.container.id}`, // `Successfully updated container ${context.container.id}`,
{ // {
timeout: ONE_MINUTE_MS, // timeout: ONE_MINUTE_MS,
}, // },
); // );
const geographyRadioButton = explorer.frame.getByRole("radio", { name: "geography-option" }); // const geographyRadioButton = explorer.frame.getByRole("radio", { name: "geography-option" });
await geographyRadioButton.click(); // await geographyRadioButton.click();
await explorer.commandBarButton(CommandBarButton.Save).click(); // await explorer.commandBarButton(CommandBarButton.Save).click();
await expect(explorer.getConsoleHeaderStatus()).toContainText( // await expect(explorer.getConsoleHeaderStatus()).toContainText(
`Successfully updated container ${context.container.id}`, // `Successfully updated container ${context.container.id}`,
{ // {
timeout: ONE_MINUTE_MS, // timeout: ONE_MINUTE_MS,
}, // },
); // );
}); // });
}); // });
+330 -330
View File
@@ -1,330 +1,330 @@
import { Locator, expect, test } from "@playwright/test"; // import { Locator, expect, test } from "@playwright/test";
import { // import {
CommandBarButton, // CommandBarButton,
DataExplorer, // DataExplorer,
ONE_MINUTE_MS, // ONE_MINUTE_MS,
TEST_AUTOSCALE_MAX_THROUGHPUT_RU_4K, // TEST_AUTOSCALE_MAX_THROUGHPUT_RU_4K,
TEST_MANUAL_THROUGHPUT_RU, // TEST_MANUAL_THROUGHPUT_RU,
TestAccount, // TestAccount,
} from "../../fx"; // } from "../../fx";
import { TestDatabaseContext, createTestDB } from "../../testData"; // import { TestDatabaseContext, createTestDB } from "../../testData";
test.describe("Shared Throughput Option Removed from Creation Dialogs", () => { // test.describe("Shared Throughput Option Removed from Creation Dialogs", () => {
let explorer: DataExplorer = null!; // let explorer: DataExplorer = null!;
test.beforeEach(async ({ page }) => { // test.beforeEach(async ({ page }) => {
explorer = await DataExplorer.open(page, TestAccount.SQL); // explorer = await DataExplorer.open(page, TestAccount.SQL);
}); // });
test("New Database panel should not show shared throughput checkbox", async () => { // test("New Database panel should not show shared throughput checkbox", async () => {
test.skip(); // test.skip();
// Open the "New Database" panel via the global command menu // // Open the "New Database" panel via the global command menu
const newDatabaseButton = await explorer.globalCommandButton("New Database"); // const newDatabaseButton = await explorer.globalCommandButton("New Database");
await newDatabaseButton.click(); // await newDatabaseButton.click();
const panel = explorer.panel("New Database"); // const panel = explorer.panel("New Database");
await panel.waitFor(); // await panel.waitFor();
// Assert that no "Provision throughput" / "Provision shared throughput" checkbox is visible // // Assert that no "Provision throughput" / "Provision shared throughput" checkbox is visible
const sharedThroughputCheckbox = panel.getByRole("checkbox", { // const sharedThroughputCheckbox = panel.getByRole("checkbox", {
name: /Provision.*throughput|Share.*throughput/i, // name: /Provision.*throughput|Share.*throughput/i,
}); // });
await expect(sharedThroughputCheckbox).not.toBeAttached(); // await expect(sharedThroughputCheckbox).not.toBeAttached();
// Close the panel without submitting // // Close the panel without submitting
const closeButton = explorer.frame.getByLabel("Close New Database"); // const closeButton = explorer.frame.getByLabel("Close New Database");
await closeButton.click(); // await closeButton.click();
await panel.waitFor({ state: "detached" }); // await panel.waitFor({ state: "detached" });
}); // });
test("New Container panel should not show shared throughput checkbox when creating new database", async () => { // test("New Container panel should not show shared throughput checkbox when creating new database", async () => {
test.skip(); // test.skip();
// Open the "New Container" panel // // Open the "New Container" panel
const newContainerButton = await explorer.globalCommandButton("New Container"); // const newContainerButton = await explorer.globalCommandButton("New Container");
await newContainerButton.click(); // await newContainerButton.click();
const panel = explorer.panel("New Container"); // const panel = explorer.panel("New Container");
await panel.waitFor(); // await panel.waitFor();
// "Create new" database should be selected by default // // "Create new" database should be selected by default
const createNewRadio = panel.getByRole("radio", { name: /Create new/i }); // const createNewRadio = panel.getByRole("radio", { name: /Create new/i });
await expect(createNewRadio).toBeChecked(); // await expect(createNewRadio).toBeChecked();
// Assert that no "Share throughput across containers" checkbox is visible // // Assert that no "Share throughput across containers" checkbox is visible
const shareThroughputCheckbox = panel.getByRole("checkbox", { // const shareThroughputCheckbox = panel.getByRole("checkbox", {
name: /Share throughput/i, // name: /Share throughput/i,
}); // });
await expect(shareThroughputCheckbox).not.toBeAttached(); // await expect(shareThroughputCheckbox).not.toBeAttached();
// Close the panel without submitting // // Close the panel without submitting
const closeButton = explorer.frame.getByLabel("Close New Container"); // const closeButton = explorer.frame.getByLabel("Close New Container");
await closeButton.click(); // await closeButton.click();
await panel.waitFor({ state: "detached" }); // await panel.waitFor({ state: "detached" });
}); // });
test("Dedicated throughput checkbox still appears for existing shared database", async () => { // test("Dedicated throughput checkbox still appears for existing shared database", async () => {
test.skip(); // test.skip();
// Create a database with shared throughput via SDK // // Create a database with shared throughput via SDK
const dbContext = await createTestDB({ throughput: 400 }); // const dbContext = await createTestDB({ throughput: 400 });
try { // try {
// Wait for the database to appear // // Wait for the database to appear
await explorer.waitForNode(dbContext.database.id); // await explorer.waitForNode(dbContext.database.id);
// Open New Container panel // // Open New Container panel
const newContainerButton = await explorer.globalCommandButton("New Container"); // const newContainerButton = await explorer.globalCommandButton("New Container");
await newContainerButton.click(); // await newContainerButton.click();
const panel = explorer.panel("New Container"); // const panel = explorer.panel("New Container");
await panel.waitFor(); // await panel.waitFor();
// Select "Use existing" and pick the shared database // // Select "Use existing" and pick the shared database
const useExistingRadio = panel.getByRole("radio", { name: /Use existing/i }); // const useExistingRadio = panel.getByRole("radio", { name: /Use existing/i });
await useExistingRadio.click(); // await useExistingRadio.click();
const databaseDropdown = panel.getByRole("combobox", { name: "Choose an existing database" }); // const databaseDropdown = panel.getByRole("combobox", { name: "Choose an existing database" });
await databaseDropdown.click(); // await databaseDropdown.click();
await explorer.frame.getByRole("option", { name: dbContext.database.id }).click(); // await explorer.frame.getByRole("option", { name: dbContext.database.id }).click();
// Assert that "Provision dedicated throughput" checkbox IS visible for a shared database // // Assert that "Provision dedicated throughput" checkbox IS visible for a shared database
const dedicatedThroughputCheckbox = panel.getByRole("checkbox", { // const dedicatedThroughputCheckbox = panel.getByRole("checkbox", {
name: /Provision dedicated throughput/i, // name: /Provision dedicated throughput/i,
}); // });
await expect(dedicatedThroughputCheckbox).toBeVisible(); // await expect(dedicatedThroughputCheckbox).toBeVisible();
// Close the panel without submitting // // Close the panel without submitting
const closeButton = explorer.frame.getByLabel("Close New Container"); // const closeButton = explorer.frame.getByLabel("Close New Container");
await closeButton.click(); // await closeButton.click();
await panel.waitFor({ state: "detached" }); // await panel.waitFor({ state: "detached" });
} finally { // } finally {
await dbContext.dispose(); // await dbContext.dispose();
} // }
}); // });
}); // });
test.describe("Database with Shared Throughput", () => { // test.describe("Database with Shared Throughput", () => {
test.skip(); // test.skip();
let dbContext: TestDatabaseContext = null!; // let dbContext: TestDatabaseContext = null!;
let explorer: DataExplorer = null!; // let explorer: DataExplorer = null!;
const containerId = "sharedcontainer"; // const containerId = "sharedcontainer";
// Helper methods // // Helper methods
const getThroughputInput = (type: "manual" | "autopilot"): Locator => { // const getThroughputInput = (type: "manual" | "autopilot"): Locator => {
return explorer.frame.getByTestId(`${type}-throughput-input`); // return explorer.frame.getByTestId(`${type}-throughput-input`);
}; // };
test.afterEach("Delete Test Database", async () => { // test.afterEach("Delete Test Database", async () => {
await dbContext?.dispose(); // await dbContext?.dispose();
}); // });
test.describe("Manual Throughput Tests", () => { // test.describe("Manual Throughput Tests", () => {
test.beforeEach(async ({ page }) => { // test.beforeEach(async ({ page }) => {
explorer = await DataExplorer.open(page, TestAccount.SQL); // explorer = await DataExplorer.open(page, TestAccount.SQL);
}); // });
test("Create database with shared manual throughput and verify Scale node in UI", async () => { // test("Create database with shared manual throughput and verify Scale node in UI", async () => {
test.skip(); // test.skip();
test.setTimeout(120000); // 2 minutes timeout // test.setTimeout(120000); // 2 minutes timeout
// Create database with shared manual throughput (400 RU/s) // // Create database with shared manual throughput (400 RU/s)
dbContext = await createTestDB({ throughput: 400 }); // dbContext = await createTestDB({ throughput: 400 });
// Verify database node appears in the tree // // Verify database node appears in the tree
const databaseNode = await explorer.waitForNode(dbContext.database.id); // const databaseNode = await explorer.waitForNode(dbContext.database.id);
expect(databaseNode).toBeDefined(); // expect(databaseNode).toBeDefined();
// Expand the database node to see child nodes // // Expand the database node to see child nodes
await databaseNode.expand(); // await databaseNode.expand();
// Verify that "Scale" node appears under the database // // Verify that "Scale" node appears under the database
const scaleNode = await explorer.waitForNode(`${dbContext.database.id}/Scale`); // const scaleNode = await explorer.waitForNode(`${dbContext.database.id}/Scale`);
expect(scaleNode).toBeDefined(); // expect(scaleNode).toBeDefined();
await expect(scaleNode.element).toBeVisible(); // await expect(scaleNode.element).toBeVisible();
}); // });
test("Add container to shared database without dedicated throughput", async () => { // test("Add container to shared database without dedicated throughput", async () => {
test.skip(); // test.skip();
// Create database with shared manual throughput // // Create database with shared manual throughput
dbContext = await createTestDB({ throughput: 400 }); // dbContext = await createTestDB({ throughput: 400 });
// Wait for the database to appear in the tree // // Wait for the database to appear in the tree
await explorer.waitForNode(dbContext.database.id); // await explorer.waitForNode(dbContext.database.id);
// Add a container to the shared database via UI // // Add a container to the shared database via UI
const newContainerButton = await explorer.globalCommandButton("New Container"); // const newContainerButton = await explorer.globalCommandButton("New Container");
await newContainerButton.click(); // await newContainerButton.click();
await explorer.whilePanelOpen( // await explorer.whilePanelOpen(
"New Container", // "New Container",
async (panel, okButton) => { // async (panel, okButton) => {
// Select "Use existing" database // // Select "Use existing" database
const useExistingRadio = panel.getByRole("radio", { name: /Use existing/i }); // const useExistingRadio = panel.getByRole("radio", { name: /Use existing/i });
await useExistingRadio.click(); // await useExistingRadio.click();
// Select the database from dropdown using the new data-testid // // Select the database from dropdown using the new data-testid
const databaseDropdown = panel.getByRole("combobox", { name: "Choose an existing database" }); // const databaseDropdown = panel.getByRole("combobox", { name: "Choose an existing database" });
await databaseDropdown.click(); // await databaseDropdown.click();
await explorer.frame.getByRole("option", { name: dbContext.database.id }).click(); // await explorer.frame.getByRole("option", { name: dbContext.database.id }).click();
// Now you can target the specific database option by its data-testid // // Now you can target the specific database option by its data-testid
//await panel.getByTestId(`database-option-${dbContext.database.id}`).click(); // //await panel.getByTestId(`database-option-${dbContext.database.id}`).click();
// Fill container id // // Fill container id
await panel.getByRole("textbox", { name: "Container id, Example Container1" }).fill(containerId); // await panel.getByRole("textbox", { name: "Container id, Example Container1" }).fill(containerId);
// Fill partition key // // Fill partition key
await panel.getByRole("textbox", { name: "Partition key" }).fill("/pk"); // await panel.getByRole("textbox", { name: "Partition key" }).fill("/pk");
// Ensure "Provision dedicated throughput" is NOT checked // // Ensure "Provision dedicated throughput" is NOT checked
const dedicatedThroughputCheckbox = panel.getByRole("checkbox", { // const dedicatedThroughputCheckbox = panel.getByRole("checkbox", {
name: /Provision dedicated throughput for this container/i, // name: /Provision dedicated throughput for this container/i,
}); // });
if (await dedicatedThroughputCheckbox.isVisible()) { // if (await dedicatedThroughputCheckbox.isVisible()) {
const isChecked = await dedicatedThroughputCheckbox.isChecked(); // const isChecked = await dedicatedThroughputCheckbox.isChecked();
if (isChecked) { // if (isChecked) {
await dedicatedThroughputCheckbox.uncheck(); // await dedicatedThroughputCheckbox.uncheck();
} // }
} // }
await okButton.click(); // await okButton.click();
}, // },
{ closeTimeout: 5 * ONE_MINUTE_MS }, // { closeTimeout: 5 * ONE_MINUTE_MS },
); // );
// Verify container was created under the database // // Verify container was created under the database
const containerNode = await explorer.waitForContainerNode(dbContext.database.id, containerId); // const containerNode = await explorer.waitForContainerNode(dbContext.database.id, containerId);
expect(containerNode).toBeDefined(); // expect(containerNode).toBeDefined();
}); // });
test("Scale shared database manual throughput", async () => { // test("Scale shared database manual throughput", async () => {
test.skip(); // test.skip();
// Create database with shared manual throughput (400 RU/s) // // Create database with shared manual throughput (400 RU/s)
dbContext = await createTestDB({ throughput: 400 }); // dbContext = await createTestDB({ throughput: 400 });
// Navigate to the scale settings by clicking the "Scale" node in the tree // // Navigate to the scale settings by clicking the "Scale" node in the tree
const databaseNode = await explorer.waitForNode(dbContext.database.id); // const databaseNode = await explorer.waitForNode(dbContext.database.id);
await databaseNode.expand(); // await databaseNode.expand();
const scaleNode = await explorer.waitForNode(`${dbContext.database.id}/Scale`); // const scaleNode = await explorer.waitForNode(`${dbContext.database.id}/Scale`);
await scaleNode.element.click(); // await scaleNode.element.click();
// Update manual throughput from 400 to 800 // // Update manual throughput from 400 to 800
await getThroughputInput("manual").fill(TEST_MANUAL_THROUGHPUT_RU.toString()); // await getThroughputInput("manual").fill(TEST_MANUAL_THROUGHPUT_RU.toString());
// Save changes // // Save changes
await explorer.commandBarButton(CommandBarButton.Save).click(); // await explorer.commandBarButton(CommandBarButton.Save).click();
// Verify success message // // Verify success message
await expect(explorer.getConsoleHeaderStatus()).toContainText( // await expect(explorer.getConsoleHeaderStatus()).toContainText(
`Successfully updated offer for database ${dbContext.database.id}`, // `Successfully updated offer for database ${dbContext.database.id}`,
{ // {
timeout: 2 * ONE_MINUTE_MS, // timeout: 2 * ONE_MINUTE_MS,
}, // },
); // );
}); // });
test("Scale shared database from manual to autoscale", async () => { // test("Scale shared database from manual to autoscale", async () => {
test.skip(); // test.skip();
// Create database with shared manual throughput (400 RU/s) // // Create database with shared manual throughput (400 RU/s)
dbContext = await createTestDB({ throughput: 400 }); // dbContext = await createTestDB({ throughput: 400 });
// Open database settings by clicking the "Scale" node // // Open database settings by clicking the "Scale" node
const databaseNode = await explorer.waitForNode(dbContext.database.id); // const databaseNode = await explorer.waitForNode(dbContext.database.id);
await databaseNode.expand(); // await databaseNode.expand();
const scaleNode = await explorer.waitForNode(`${dbContext.database.id}/Scale`); // const scaleNode = await explorer.waitForNode(`${dbContext.database.id}/Scale`);
await scaleNode.element.click(); // await scaleNode.element.click();
// Switch to Autoscale // // Switch to Autoscale
const autoscaleRadio = explorer.frame.getByText("Autoscale", { exact: true }); // const autoscaleRadio = explorer.frame.getByText("Autoscale", { exact: true });
await autoscaleRadio.click(); // await autoscaleRadio.click();
// Set autoscale max throughput to 1000 // // Set autoscale max throughput to 1000
//await getThroughputInput("autopilot").fill(TEST_AUTOSCALE_THROUGHPUT_RU.toString()); // //await getThroughputInput("autopilot").fill(TEST_AUTOSCALE_THROUGHPUT_RU.toString());
// Save changes // // Save changes
await explorer.commandBarButton(CommandBarButton.Save).click(); // await explorer.commandBarButton(CommandBarButton.Save).click();
await expect(explorer.getConsoleHeaderStatus()).toContainText( // await expect(explorer.getConsoleHeaderStatus()).toContainText(
`Successfully updated offer for database ${dbContext.database.id}`, // `Successfully updated offer for database ${dbContext.database.id}`,
{ // {
timeout: 2 * ONE_MINUTE_MS, // timeout: 2 * ONE_MINUTE_MS,
}, // },
); // );
}); // });
}); // });
test.describe("Autoscale Throughput Tests", () => { // test.describe("Autoscale Throughput Tests", () => {
test.beforeEach(async ({ page }) => { // test.beforeEach(async ({ page }) => {
explorer = await DataExplorer.open(page, TestAccount.SQL); // explorer = await DataExplorer.open(page, TestAccount.SQL);
}); // });
test("Create database with shared autoscale throughput and verify Scale node in UI", async () => { // test("Create database with shared autoscale throughput and verify Scale node in UI", async () => {
test.skip(); // test.skip();
test.setTimeout(120000); // 2 minutes timeout // test.setTimeout(120000); // 2 minutes timeout
// Create database with shared autoscale throughput (max 1000 RU/s) // // Create database with shared autoscale throughput (max 1000 RU/s)
dbContext = await createTestDB({ maxThroughput: 1000 }); // dbContext = await createTestDB({ maxThroughput: 1000 });
// Verify database node appears // // Verify database node appears
const databaseNode = await explorer.waitForNode(dbContext.database.id); // const databaseNode = await explorer.waitForNode(dbContext.database.id);
expect(databaseNode).toBeDefined(); // expect(databaseNode).toBeDefined();
// Expand the database node to see child nodes // // Expand the database node to see child nodes
await databaseNode.expand(); // await databaseNode.expand();
// Verify that "Scale" node appears under the database // // Verify that "Scale" node appears under the database
const scaleNode = await explorer.waitForNode(`${dbContext.database.id}/Scale`); // const scaleNode = await explorer.waitForNode(`${dbContext.database.id}/Scale`);
expect(scaleNode).toBeDefined(); // expect(scaleNode).toBeDefined();
await expect(scaleNode.element).toBeVisible(); // await expect(scaleNode.element).toBeVisible();
}); // });
test("Scale shared database autoscale throughput", async () => { // test("Scale shared database autoscale throughput", async () => {
test.skip(); // test.skip();
// Create database with shared autoscale throughput (max 1000 RU/s) // // Create database with shared autoscale throughput (max 1000 RU/s)
dbContext = await createTestDB({ maxThroughput: 1000 }); // dbContext = await createTestDB({ maxThroughput: 1000 });
// Open database settings // // Open database settings
const databaseNode = await explorer.waitForNode(dbContext.database.id); // const databaseNode = await explorer.waitForNode(dbContext.database.id);
await databaseNode.expand(); // await databaseNode.expand();
const scaleNode = await explorer.waitForNode(`${dbContext.database.id}/Scale`); // const scaleNode = await explorer.waitForNode(`${dbContext.database.id}/Scale`);
await scaleNode.element.click(); // await scaleNode.element.click();
// Update autoscale max throughput from 1000 to 4000 // // Update autoscale max throughput from 1000 to 4000
await getThroughputInput("autopilot").fill(TEST_AUTOSCALE_MAX_THROUGHPUT_RU_4K.toString()); // await getThroughputInput("autopilot").fill(TEST_AUTOSCALE_MAX_THROUGHPUT_RU_4K.toString());
// Save changes // // Save changes
await explorer.commandBarButton(CommandBarButton.Save).click(); // await explorer.commandBarButton(CommandBarButton.Save).click();
// Verify success message // // Verify success message
await expect(explorer.getConsoleHeaderStatus()).toContainText( // await expect(explorer.getConsoleHeaderStatus()).toContainText(
`Successfully updated offer for database ${dbContext.database.id}`, // `Successfully updated offer for database ${dbContext.database.id}`,
{ // {
timeout: 2 * ONE_MINUTE_MS, // timeout: 2 * ONE_MINUTE_MS,
}, // },
); // );
}); // });
test("Scale shared database from autoscale to manual", async () => { // test("Scale shared database from autoscale to manual", async () => {
test.skip(); // test.skip();
// Create database with shared autoscale throughput (max 1000 RU/s) // // Create database with shared autoscale throughput (max 1000 RU/s)
dbContext = await createTestDB({ maxThroughput: 1000 }); // dbContext = await createTestDB({ maxThroughput: 1000 });
// Open database settings // // Open database settings
const databaseNode = await explorer.waitForNode(dbContext.database.id); // const databaseNode = await explorer.waitForNode(dbContext.database.id);
await databaseNode.expand(); // await databaseNode.expand();
const scaleNode = await explorer.waitForNode(`${dbContext.database.id}/Scale`); // const scaleNode = await explorer.waitForNode(`${dbContext.database.id}/Scale`);
await scaleNode.element.click(); // await scaleNode.element.click();
// Switch to Manual // // Switch to Manual
const manualRadio = explorer.frame.getByText("Manual", { exact: true }); // const manualRadio = explorer.frame.getByText("Manual", { exact: true });
await manualRadio.click(); // await manualRadio.click();
// Save changes // // Save changes
await explorer.commandBarButton(CommandBarButton.Save).click(); // await explorer.commandBarButton(CommandBarButton.Save).click();
// Verify success message // // Verify success message
await expect(explorer.getConsoleHeaderStatus()).toContainText( // await expect(explorer.getConsoleHeaderStatus()).toContainText(
`Successfully updated offer for database ${dbContext.database.id}`, // `Successfully updated offer for database ${dbContext.database.id}`,
{ timeout: 2 * ONE_MINUTE_MS }, // { timeout: 2 * ONE_MINUTE_MS },
); // );
}); // });
}); // });
}); // });
@@ -1,112 +1,112 @@
import { expect, test } from "@playwright/test"; // import { expect, test } from "@playwright/test";
import { CommandBarButton, DataExplorer, ONE_MINUTE_MS, TestAccount } from "../../fx"; // import { CommandBarButton, DataExplorer, ONE_MINUTE_MS, TestAccount } from "../../fx";
import { createTestSQLContainer, TestContainerContext } from "../../testData"; // import { createTestSQLContainer, TestContainerContext } from "../../testData";
test.describe("Throughput bucket settings", () => { // test.describe("Throughput bucket settings", () => {
let context: TestContainerContext = null!; // let context: TestContainerContext = null!;
let explorer: DataExplorer = null!; // let explorer: DataExplorer = null!;
test.beforeAll("Create Test Database", async () => { // test.beforeAll("Create Test Database", async () => {
context = await createTestSQLContainer(); // context = await createTestSQLContainer();
}); // });
test.beforeEach("Open Throughput Bucket Settings", async ({ browser }) => { // test.beforeEach("Open Throughput Bucket Settings", async ({ browser }) => {
const page = await browser.newPage(); // const page = await browser.newPage();
explorer = await DataExplorer.open(page, TestAccount.SQL); // explorer = await DataExplorer.open(page, TestAccount.SQL);
// Click Scale & Settings and open Throughput Bucket Settings tab // // Click Scale & Settings and open Throughput Bucket Settings tab
await explorer.openScaleAndSettings(context); // await explorer.openScaleAndSettings(context);
const throughputBucketTab = explorer.frame.getByTestId("settings-tab-header/ThroughputBucketsTab"); // const throughputBucketTab = explorer.frame.getByTestId("settings-tab-header/ThroughputBucketsTab");
await throughputBucketTab.click(); // await throughputBucketTab.click();
}); // });
// Delete database only if not running in CI // // Delete database only if not running in CI
if (!process.env.CI) { // if (!process.env.CI) {
test.afterAll("Delete Test Database", async () => { // test.afterAll("Delete Test Database", async () => {
await context?.dispose(); // await context?.dispose();
}); // });
} // }
test("Activate throughput bucket #2", async () => { // test("Activate throughput bucket #2", async () => {
test.skip(); // test.skip();
// Activate bucket 2 // // Activate bucket 2
const bucket2Toggle = explorer.frame.getByTestId("bucket-2-active-toggle"); // const bucket2Toggle = explorer.frame.getByTestId("bucket-2-active-toggle");
await bucket2Toggle.click(); // await bucket2Toggle.click();
await explorer.commandBarButton(CommandBarButton.Save).click(); // await explorer.commandBarButton(CommandBarButton.Save).click();
await expect(explorer.getConsoleHeaderStatus()).toContainText( // await expect(explorer.getConsoleHeaderStatus()).toContainText(
`Successfully updated offer for collection ${context.container.id}`, // `Successfully updated offer for collection ${context.container.id}`,
{ // {
timeout: 2 * ONE_MINUTE_MS, // timeout: 2 * ONE_MINUTE_MS,
}, // },
); // );
}); // });
test("Activate throughput buckets #1 and #2", async () => { // test("Activate throughput buckets #1 and #2", async () => {
test.skip(); // test.skip();
// Activate bucket 1 // // Activate bucket 1
const bucket1Toggle = explorer.frame.getByTestId("bucket-1-active-toggle"); // const bucket1Toggle = explorer.frame.getByTestId("bucket-1-active-toggle");
await bucket1Toggle.click(); // await bucket1Toggle.click();
// Activate bucket 2 // // Activate bucket 2
const bucket2Toggle = explorer.frame.getByTestId("bucket-2-active-toggle"); // const bucket2Toggle = explorer.frame.getByTestId("bucket-2-active-toggle");
await bucket2Toggle.click(); // await bucket2Toggle.click();
await explorer.commandBarButton(CommandBarButton.Save).click(); // await explorer.commandBarButton(CommandBarButton.Save).click();
await expect(explorer.getConsoleHeaderStatus()).toContainText( // await expect(explorer.getConsoleHeaderStatus()).toContainText(
`Successfully updated offer for collection ${context.container.id}`, // `Successfully updated offer for collection ${context.container.id}`,
{ // {
timeout: 2 * ONE_MINUTE_MS, // timeout: 2 * ONE_MINUTE_MS,
}, // },
); // );
}); // });
test("Set throughput percentage for bucket #1", async () => { // test("Set throughput percentage for bucket #1", async () => {
test.skip(); // test.skip();
// Set throughput percentage for bucket 1 (inactive) - Should be disabled // // Set throughput percentage for bucket 1 (inactive) - Should be disabled
const bucket1PercentageInput = explorer.frame.getByTestId("bucket-1-percentage-input"); // const bucket1PercentageInput = explorer.frame.getByTestId("bucket-1-percentage-input");
expect(bucket1PercentageInput).toBeDisabled(); // expect(bucket1PercentageInput).toBeDisabled();
// Activate bucket 1 // // Activate bucket 1
const bucket1Toggle = explorer.frame.getByTestId("bucket-1-active-toggle"); // const bucket1Toggle = explorer.frame.getByTestId("bucket-1-active-toggle");
await bucket1Toggle.click(); // await bucket1Toggle.click();
expect(bucket1PercentageInput).toBeEnabled(); // expect(bucket1PercentageInput).toBeEnabled();
await bucket1PercentageInput.fill("40"); // await bucket1PercentageInput.fill("40");
await explorer.commandBarButton(CommandBarButton.Save).click(); // await explorer.commandBarButton(CommandBarButton.Save).click();
await expect(explorer.getConsoleHeaderStatus()).toContainText( // await expect(explorer.getConsoleHeaderStatus()).toContainText(
`Successfully updated offer for collection ${context.container.id}`, // `Successfully updated offer for collection ${context.container.id}`,
{ // {
timeout: 2 * ONE_MINUTE_MS, // timeout: 2 * ONE_MINUTE_MS,
}, // },
); // );
}); // });
test("Set default throughput bucket", async () => { // test("Set default throughput bucket", async () => {
test.skip(); // test.skip();
// There are no active throughput buckets so they all should be disabled // // There are no active throughput buckets so they all should be disabled
const defaultThroughputBucketDropdown = explorer.frame.getByTestId("default-throughput-bucket-dropdown"); // const defaultThroughputBucketDropdown = explorer.frame.getByTestId("default-throughput-bucket-dropdown");
await defaultThroughputBucketDropdown.click(); // await defaultThroughputBucketDropdown.click();
const bucket1Option = explorer.frame.getByRole("option", { name: "Bucket 1" }); // const bucket1Option = explorer.frame.getByRole("option", { name: "Bucket 1" });
expect(bucket1Option).toBeDisabled(); // expect(bucket1Option).toBeDisabled();
// Activate bucket 1 // // Activate bucket 1
const bucket1Toggle = explorer.frame.getByTestId("bucket-1-active-toggle"); // const bucket1Toggle = explorer.frame.getByTestId("bucket-1-active-toggle");
await bucket1Toggle.click(); // await bucket1Toggle.click();
// Open dropdown again // // Open dropdown again
await defaultThroughputBucketDropdown.click(); // await defaultThroughputBucketDropdown.click();
expect(bucket1Option).toBeEnabled(); // expect(bucket1Option).toBeEnabled();
// Select bucket 1 as default // // Select bucket 1 as default
await bucket1Option.click(); // await bucket1Option.click();
await explorer.commandBarButton(CommandBarButton.Save).click(); // await explorer.commandBarButton(CommandBarButton.Save).click();
await expect(explorer.getConsoleHeaderStatus()).toContainText( // await expect(explorer.getConsoleHeaderStatus()).toContainText(
`Successfully updated offer for collection ${context.container.id}`, // `Successfully updated offer for collection ${context.container.id}`,
{ // {
timeout: 2 * ONE_MINUTE_MS, // timeout: 2 * ONE_MINUTE_MS,
}, // },
); // );
}); // });
}); // });
+34 -34
View File
@@ -1,41 +1,41 @@
import { expect, test } from "@playwright/test"; // import { expect, test } from "@playwright/test";
import { DataExplorer, TestAccount } from "../fx"; // import { DataExplorer, TestAccount } from "../fx";
test("Self Serve", async ({ page, browserName }) => { // test("Self Serve", async ({ page, browserName }) => {
test.skip(); // test.skip();
/* Skipping this test which fails on webkit only. Clicking on the dropdown does not open the dropdown. // /* Skipping this test which fails on webkit only. Clicking on the dropdown does not open the dropdown.
It fails with the error below which seems to indicate that some <div> (with class "ms-Stack css-128", the label of the dropdown?) is intercepting the click. // It fails with the error below which seems to indicate that some <div> (with class "ms-Stack css-128", the label of the dropdown?) is intercepting the click.
- retrying click action, attempt #555 // - retrying click action, attempt #555
- waiting 500ms // - waiting 500ms
- waiting for element to be visible, enabled and stable // - waiting for element to be visible, enabled and stable
- element is visible, enabled and stable // - element is visible, enabled and stable
- scrolling into view if needed // - scrolling into view if needed
- done scrolling // - done scrolling
- <div class="ms-Stack css-128">…</div> from <div id="selfServeContent" class="selfServeComponentC…>…</div> subtree intercepts pointer events // - <div class="ms-Stack css-128">…</div> from <div id="selfServeContent" class="selfServeComponentC…>…</div> subtree intercepts pointer events
Adding waiting for page to load, forcing click with .click({ force: true }) or setting page viewport with page.setViewportSize() did not help. // Adding waiting for page to load, forcing click with .click({ force: true }) or setting page viewport with page.setViewportSize() did not help.
*/ // */
test.skip( // test.skip(
browserName === "webkit", // browserName === "webkit",
"This test only fails on Webkit: clicking on the dropdown does not open the dropdown.", // "This test only fails on Webkit: clicking on the dropdown does not open the dropdown.",
); // );
const explorer = await DataExplorer.open(page, TestAccount.SQL, "selfServe.html"); // const explorer = await DataExplorer.open(page, TestAccount.SQL, "selfServe.html");
const loggingToggle = explorer.frame.locator("#enableLogging-toggle-input"); // const loggingToggle = explorer.frame.locator("#enableLogging-toggle-input");
await expect(loggingToggle).toBeEnabled(); // await expect(loggingToggle).toBeEnabled();
const regionDropdown = explorer.frame.getByText("Select a region"); // const regionDropdown = explorer.frame.getByText("Select a region");
await regionDropdown.click(); // await regionDropdown.click();
await explorer.frame.getByRole("option").first().click(); // await explorer.frame.getByRole("option").first().click();
const currentRegionLabel = explorer.frame.getByLabel("Current Region"); // const currentRegionLabel = explorer.frame.getByLabel("Current Region");
await currentRegionLabel.waitFor(); // await currentRegionLabel.waitFor();
await expect(currentRegionLabel).toHaveText(/current region selected is .*/); // await expect(currentRegionLabel).toHaveText(/current region selected is .*/);
await expect(loggingToggle).toBeDisabled(); // await expect(loggingToggle).toBeDisabled();
await explorer.frame.locator("#enableDbLevelThroughput-toggle-input").click(); // await explorer.frame.locator("#enableDbLevelThroughput-toggle-input").click();
const slider = explorer.frame.getByLabel("Database Throughput"); // const slider = explorer.frame.getByLabel("Database Throughput");
await slider.waitFor(); // await slider.waitFor();
await expect(slider).toBeAttached(); // await expect(slider).toBeAttached();
}); // });
+30 -30
View File
@@ -1,37 +1,37 @@
import { expect, test } from "@playwright/test"; // import { expect, test } from "@playwright/test";
import { DataExplorer, TEST_AUTOSCALE_THROUGHPUT_RU, TestAccount, generateUniqueName } from "../fx"; // import { DataExplorer, TEST_AUTOSCALE_THROUGHPUT_RU, TestAccount, generateUniqueName } from "../fx";
test("Tables CRUD", async ({ page }) => { // test("Tables CRUD", async ({ page }) => {
test.skip(); // test.skip();
const tableId = generateUniqueName("table"); // A unique table name IS needed because the database is shared when using Table Storage. // const tableId = generateUniqueName("table"); // A unique table name IS needed because the database is shared when using Table Storage.
const explorer = await DataExplorer.open(page, TestAccount.Tables); // const explorer = await DataExplorer.open(page, TestAccount.Tables);
const newTableButton = explorer.frame.getByTestId("GlobalCommands").getByRole("button", { name: "New Table" }); // const newTableButton = explorer.frame.getByTestId("GlobalCommands").getByRole("button", { name: "New Table" });
await newTableButton.click(); // await newTableButton.click();
await explorer.whilePanelOpen( // await explorer.whilePanelOpen(
"New Table", // "New Table",
async (panel, okButton) => { // async (panel, okButton) => {
await panel.getByRole("textbox", { name: "Table id, Example Table1" }).fill(tableId); // await panel.getByRole("textbox", { name: "Table id, Example Table1" }).fill(tableId);
await panel.getByTestId("autoscaleRUInput").fill(TEST_AUTOSCALE_THROUGHPUT_RU.toString()); // await panel.getByTestId("autoscaleRUInput").fill(TEST_AUTOSCALE_THROUGHPUT_RU.toString());
await okButton.click(); // await okButton.click();
}, // },
{ closeTimeout: 5 * 60 * 1000 }, // { closeTimeout: 5 * 60 * 1000 },
); // );
const tableNode = await explorer.waitForContainerNode("TablesDB", tableId); // const tableNode = await explorer.waitForContainerNode("TablesDB", tableId);
await tableNode.openContextMenu(); // await tableNode.openContextMenu();
await tableNode.contextMenuItem("Delete Table").click(); // await tableNode.contextMenuItem("Delete Table").click();
await explorer.whilePanelOpen( // await explorer.whilePanelOpen(
"Delete Table", // "Delete Table",
async (panel, okButton) => { // async (panel, okButton) => {
await panel.getByRole("textbox", { name: "Confirm by typing the table id" }).fill(tableId); // await panel.getByRole("textbox", { name: "Confirm by typing the table id" }).fill(tableId);
await okButton.click(); // await okButton.click();
}, // },
{ closeTimeout: 5 * 60 * 1000 }, // { closeTimeout: 5 * 60 * 1000 },
); // );
await expect(tableNode.element).not.toBeAttached(); // await expect(tableNode.element).not.toBeAttached();
}); // });