Fix change partition key FTs

This commit is contained in:
Bikram Choudhury
2026-01-08 17:22:13 +05:30
parent b71ea50972
commit cee1bc61ca

View File

@@ -1,104 +1,142 @@
// import { expect, test } from "@playwright/test"; import { expect, test } from "@playwright/test";
// import { DataExplorer, getDropdownItemByNameOrPosition, TestAccount } from "../../fx"; import { DataExplorer, TestAccount } from "../../fx";
// import { createTestSQLContainer, TestContainerContext } from "../../testData"; import { createTestSQLContainer, TestContainerContext } from "../../testData";
// test.describe("Change Partition Key", () => { test.describe("Change Partition Key", () => {
// let context: TestContainerContext = null!; let context: TestContainerContext = null!;
// let explorer: DataExplorer = null!; let explorer: DataExplorer = null!;
// const newPartitionKeyPath = "newPartitionKey"; const newPartitionKeyPath = "newPartitionKey";
// const newContainerId = "testcontainer_1"; const newContainerId = "testcontainer_1";
let previousJobName: string | undefined;
// test.beforeAll("Create Test Database", async () => { test.beforeAll("Create Test Database", async () => {
// context = await createTestSQLContainer(); context = await createTestSQLContainer();
// }); });
// test.beforeEach("Open container settings", async ({ page }) => { test.beforeEach("Open container settings", async ({ page }) => {
// explorer = await DataExplorer.open(page, TestAccount.SQL); explorer = await DataExplorer.open(page, TestAccount.SQL);
// // Click Scale & Settings and open Partition Key tab // Click Scale & Settings and open Partition Key tab
// await explorer.openScaleAndSettings(context); await explorer.openScaleAndSettings(context);
// const PartitionKeyTab = explorer.frame.getByTestId("settings-tab-header/PartitionKeyTab"); const PartitionKeyTab = explorer.frame.getByTestId("settings-tab-header/PartitionKeyTab");
// await expect(PartitionKeyTab).toBeVisible(); await expect(PartitionKeyTab).toBeVisible();
// await PartitionKeyTab.click(); await PartitionKeyTab.click();
// }); });
// // Delete database only if not running in CI // Delete database only if not running in CI
// if (!process.env.CI) { if (!process.env.CI) {
// test.afterEach("Delete Test Database", async () => { test.afterEach("Delete Test Database", async () => {
// await context?.dispose(); await context?.dispose();
// }); });
// } }
// test("Change partition key path", async () => { test("Change partition key path", async ({ page }) => {
// await expect(explorer.frame.getByText("/partitionKey")).toBeVisible(); await expect(explorer.frame.getByText("/partitionKey")).toBeVisible();
// await expect(explorer.frame.getByText("Change partition key")).toBeVisible(); await expect(explorer.frame.getByText("Change partition key")).toBeVisible();
// await expect(explorer.frame.getByText(/To safeguard the integrity of/)).toBeVisible(); await expect(explorer.frame.getByText(/To safeguard the integrity of/)).toBeVisible();
// await expect(explorer.frame.getByText(/To change the partition key/)).toBeVisible(); await expect(explorer.frame.getByText(/To change the partition key/)).toBeVisible();
// const changePartitionKeyButton = explorer.frame.getByTestId("change-partition-key-button"); const changePartitionKeyButton = explorer.frame.getByTestId("change-partition-key-button");
// expect(changePartitionKeyButton).toBeVisible(); expect(changePartitionKeyButton).toBeVisible();
// await changePartitionKeyButton.click(); await changePartitionKeyButton.click();
// // Fill out new partition key form in the panel // Fill out new partition key form in the panel
// const changePkPanel = explorer.frame.getByTestId(`Panel:Change partition key`); const changePkPanel = explorer.frame.getByTestId(`Panel:Change partition key`);
// await expect(changePkPanel.getByText(context.database.id)).toBeVisible(); await expect(changePkPanel.getByText(context.database.id)).toBeVisible();
// await expect(explorer.frame.getByRole("heading", { name: "Change partition key" })).toBeVisible(); await expect(explorer.frame.getByRole("heading", { name: "Change partition key" })).toBeVisible();
// await expect(explorer.frame.getByText(/When changing a container/)).toBeVisible(); await expect(explorer.frame.getByText(/When changing a container/)).toBeVisible();
// // Try to switch to new container // Try to switch to new container
// await expect(changePkPanel.getByText("New container")).toBeVisible(); await expect(changePkPanel.getByText("New container")).toBeVisible();
// await expect(changePkPanel.getByText("Existing container")).toBeVisible(); await expect(changePkPanel.getByText("Existing container")).toBeVisible();
// await expect(changePkPanel.getByTestId("new-container-id-input")).toBeVisible(); await expect(changePkPanel.getByTestId("new-container-id-input")).toBeVisible();
// changePkPanel.getByTestId("new-container-id-input").fill(newContainerId); changePkPanel.getByTestId("new-container-id-input").fill(newContainerId);
// await expect(changePkPanel.getByTestId("new-container-partition-key-input")).toBeVisible(); await expect(changePkPanel.getByTestId("new-container-partition-key-input")).toBeVisible();
// changePkPanel.getByTestId("new-container-partition-key-input").fill(newPartitionKeyPath); changePkPanel.getByTestId("new-container-partition-key-input").fill(newPartitionKeyPath);
// await expect(changePkPanel.getByTestId("add-sub-partition-key-button")).toBeVisible(); await expect(changePkPanel.getByTestId("add-sub-partition-key-button")).toBeVisible();
// changePkPanel.getByTestId("add-sub-partition-key-button").click(); changePkPanel.getByTestId("add-sub-partition-key-button").click();
// await expect(changePkPanel.getByTestId("new-container-sub-partition-key-input-0")).toBeVisible(); await expect(changePkPanel.getByTestId("new-container-sub-partition-key-input-0")).toBeVisible();
// await expect(changePkPanel.getByTestId("remove-sub-partition-key-button-0")).toBeVisible(); await expect(changePkPanel.getByTestId("remove-sub-partition-key-button-0")).toBeVisible();
// await expect(changePkPanel.getByTestId("hierarchical-partitioning-info-text")).toBeVisible(); await expect(changePkPanel.getByTestId("hierarchical-partitioning-info-text")).toBeVisible();
// await changePkPanel.getByTestId("remove-sub-partition-key-button-0").click(); await changePkPanel.getByTestId("remove-sub-partition-key-button-0").click();
// await changePkPanel.getByTestId("Panel/OkButton").click(); await changePkPanel.getByTestId("Panel/OkButton").click();
// await expect(changePkPanel).not.toBeVisible({ timeout: 5 * 60 * 1000 }); 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 },
);
// // Verify partition key change job await expect(changePkPanel).not.toBeVisible({ timeout: 5 * 60 * 1000 });
// 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");
// const jobRow = explorer.frame.locator(".ms-ProgressIndicator-itemDescription"); // Verify partition key change job
// // await expect(jobRow.getByText("Pending")).toBeVisible({ timeout: 30 * 1000 }); const jobText = explorer.frame.getByText(/Partition key change job/);
// await expect(jobRow.getByText("Completed")).toBeVisible({ timeout: 5 * 60 * 1000 }); 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 newContainerNode = await explorer.waitForContainerNode(context.database.id, newContainerId); const jobRow = explorer.frame.locator(".ms-ProgressIndicator-itemDescription");
// expect(newContainerNode).not.toBeNull(); // await expect(jobRow.getByText("Pending")).toBeVisible({ timeout: 30 * 1000 });
await expect(jobRow.getByText("Completed")).toBeVisible({ timeout: 5 * 60 * 1000 });
// // Now try to switch to existing container const newContainerNode = await explorer.waitForContainerNode(context.database.id, newContainerId);
// await changePartitionKeyButton.click(); expect(newContainerNode).not.toBeNull();
// await changePkPanel.getByText("Existing container").click();
// await changePkPanel.getByLabel("Use existing container").check();
// await changePkPanel.getByText("Choose an existing container").click();
// const containerDropdownItem = await getDropdownItemByNameOrPosition( // Now try to switch to existing container
// explorer.frame, // Ensure this job name is different from the previously processed job name
// { name: newContainerId }, previousJobName = jobName;
// { ariaLabel: "Existing Containers" },
// );
// await containerDropdownItem.click();
// await changePkPanel.getByTestId("Panel/OkButton").click(); await changePartitionKeyButton.click();
// await explorer.frame.getByRole("button", { name: "Cancel" }).click(); await changePkPanel.getByText("Existing container").click();
await changePkPanel.getByLabel("Use existing container").check();
await changePkPanel.getByText("Choose an existing container").click();
// // Dismiss overlay if it appears const containerDropdownItem = await explorer.getDropdownItemByName(newContainerId, "Existing Containers");
// const overlayFrame = explorer.frame.locator("#webpack-dev-server-client-overlay").first(); await containerDropdownItem.click();
// if (await overlayFrame.count()) {
// await overlayFrame.contentFrame().getByLabel("Dismiss").click(); let secondJobName: string | undefined;
// } await Promise.all([
// const cancelledJobRow = explorer.frame.getByTestId("Tab:tab0"); page.waitForRequest(
// await expect(cancelledJobRow.getByText("Cancelled")).toBeVisible({ timeout: 30 * 1000 }); (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();
// 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);
}
});
});