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