Compare commits

...

13 Commits

Author SHA1 Message Date
Asier Isayas
b559976a42 for computedProperties use nosql2 2026-01-21 14:24:42 -08:00
Asier Isayas
a4b0572f91 npm run format 2026-01-21 11:08:04 -08:00
Asier Isayas
22e9580ca4 remove offline/online migration test 2026-01-21 11:06:12 -08:00
Asier Isayas
c561a982fb delete database after each test 2026-01-21 11:05:55 -08:00
Asier Isayas
c971d21698 Merge branch 'master' of https://github.com/Azure/cosmos-explorer into users/aisayas/fix-playwright-tests-final 2026-01-21 10:11:55 -08:00
Laurent Nguyen
6dce2632c8 fix: prevent race condition by initializing scenario tracking after config is set (#2339)
Co-authored-by: Laurent Nguyen <languye@microsoft.com>
2026-01-21 17:28:08 +01:00
Asier Isayas
43b407a190 nit 2026-01-21 07:29:53 -08:00
Asier Isayas
dd93b70a61 dont delete database 2026-01-21 06:51:26 -08:00
Asier Isayas
4270151e97 add second github sql account 2026-01-21 06:40:26 -08:00
BChoudhury-ms
80ad5f10d4 update args type for FT data creation (#2330) 2026-01-21 15:59:26 +05:30
BChoudhury-ms
f02611c90e Fix: Disable Complete action when any job update is in progress (#2335)
* Fix: Disable Complete action when any job update is in progress

- Updated CopyJobActionMenu to disable Complete button when any action is being performed
- Added comprehensive tests to verify Complete button is disabled during updates
- Improved user experience by preventing concurrent actions on copy jobs

This PR was generated by GitHub Copilot CLI

* Fix lint error: Remove unused variable in CopyJobActionMenu (#2336)

* Initial plan

* Fix lint error: Remove unused variable 'updatingAction' in CopyJobActionMenu.tsx

Co-authored-by: BChoudhury-ms <201893606+BChoudhury-ms@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: BChoudhury-ms <201893606+BChoudhury-ms@users.noreply.github.com>

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: BChoudhury-ms <201893606+BChoudhury-ms@users.noreply.github.com>
2026-01-21 11:55:15 +05:30
Dmitry Shilov
9646dfcf04 feat: Enhance restore container functionality and UI updates (#2217) 2026-01-20 14:15:53 +01:00
sakshigupta12feb
90f3c3a79e Reverted the header sub header logic (#2337)
* updated the text

* updated margin

---------

Co-authored-by: Sakshi Gupta <sakshig@microsoft.com>
2026-01-19 21:16:28 +05:30
26 changed files with 528 additions and 436 deletions

View File

@@ -189,6 +189,9 @@ jobs:
NOSQL_TESTACCOUNT_TOKEN=$(az account get-access-token --scope "https://github-e2etests-sql.documents.azure.com/.default" -o tsv --query accessToken)
echo "::add-mask::$NOSQL_TESTACCOUNT_TOKEN"
echo NOSQL_TESTACCOUNT_TOKEN=$NOSQL_TESTACCOUNT_TOKEN >> $GITHUB_ENV
NOSQL2_TESTACCOUNT_TOKEN=$(az account get-access-token --scope "https://github-e2etests-sql-2.documents.azure.com/.default" -o tsv --query accessToken)
echo "::add-mask::$NOSQL2_TESTACCOUNT_TOKEN"
echo NOSQL2_TESTACCOUNT_TOKEN=$NOSQL2_TESTACCOUNT_TOKEN >> $GITHUB_ENV
NOSQL_READONLY_TESTACCOUNT_TOKEN=$(az account get-access-token --scope "https://github-e2etests-sql-readonly.documents.azure.com/.default" -o tsv --query accessToken)
echo "::add-mask::$NOSQL_READONLY_TESTACCOUNT_TOKEN"
echo NOSQL_READONLY_TESTACCOUNT_TOKEN=$NOSQL_READONLY_TESTACCOUNT_TOKEN >> $GITHUB_ENV

View File

@@ -46,6 +46,10 @@ export type DataExploreMessageV3 =
params: {
updateType: "created" | "deleted" | "settings";
};
}
| {
type: FabricMessageTypes.RestoreContainer;
params: [];
};
export interface GetCosmosTokenMessageOptions {
verb: "connect" | "delete" | "get" | "head" | "options" | "patch" | "post" | "put" | "trace";

View File

@@ -516,7 +516,7 @@ describe("CopyJobActionMenu", () => {
expect(screen.getByText("Cancel")).toBeInTheDocument();
});
it("should handle complete action disabled state for online jobs", () => {
it("should disable complete action when job is being updated", () => {
const job = createMockJob({
Status: CopyJobStatusType.InProgress,
Mode: CopyJobMigrationType.Online,
@@ -530,8 +530,34 @@ describe("CopyJobActionMenu", () => {
const completeButton = screen.getByText("Complete");
fireEvent.click(completeButton);
// Simulate dialog confirmation to trigger state update
const [, , , onOkCallback] = mockShowOkCancelModalDialog.mock.calls[0];
onOkCallback();
fireEvent.click(actionButton);
expect(screen.getByText("Complete")).toBeInTheDocument();
const completeButtonAfterClick = screen.getByText("Complete").closest("button");
expect(completeButtonAfterClick).toBeInTheDocument();
expect(completeButtonAfterClick).toHaveAttribute("aria-disabled", "true");
});
it("should disable complete action when any other action is being performed", () => {
const job = createMockJob({
Status: CopyJobStatusType.InProgress,
Mode: CopyJobMigrationType.Online,
});
render(<TestComponentWrapper job={job} />);
const actionButton = screen.getByRole("button", { name: "Actions" });
fireEvent.click(actionButton);
const pauseButton = screen.getByText("Pause");
fireEvent.click(pauseButton);
fireEvent.click(actionButton);
const completeButtonAfterClick = screen.getByText("Complete").closest("button");
expect(completeButtonAfterClick).toBeInTheDocument();
expect(completeButtonAfterClick).toHaveAttribute("aria-disabled", "true");
});
});

View File

@@ -61,7 +61,6 @@ const CopyJobActionMenu: React.FC<CopyJobActionMenuProps> = ({ job, handleClick
const getMenuItems = (): IContextualMenuProps["items"] => {
const isThisJobUpdating = updatingJobAction?.jobName === job.Name;
const updatingAction = updatingJobAction?.action;
const baseItems = [
{
@@ -105,7 +104,7 @@ const CopyJobActionMenu: React.FC<CopyJobActionMenuProps> = ({ job, handleClick
text: ContainerCopyMessages.MonitorJobs.Actions.complete,
iconProps: { iconName: "CheckMark" },
onClick: () => showActionConfirmationDialog(job, CopyJobActions.complete),
disabled: isThisJobUpdating && updatingAction === CopyJobActions.complete,
disabled: isThisJobUpdating,
});
}
return filteredItems;

View File

@@ -7,7 +7,7 @@ import {
AddGlobalSecondaryIndexPanelProps,
} from "Explorer/Panes/AddGlobalSecondaryIndexPanel/AddGlobalSecondaryIndexPanel";
import { useDatabases } from "Explorer/useDatabases";
import { isFabric, isFabricNative } from "Platform/Fabric/FabricUtil";
import { isFabric, isFabricNative, openRestoreContainerDialog } from "Platform/Fabric/FabricUtil";
import { Action } from "Shared/Telemetry/TelemetryConstants";
import { traceOpen } from "Shared/Telemetry/TelemetryProcessor";
import { ReactTabKind, useTabs } from "hooks/useTabs";
@@ -35,6 +35,7 @@ import StoredProcedure from "./Tree/StoredProcedure";
import Trigger from "./Tree/Trigger";
import UserDefinedFunction from "./Tree/UserDefinedFunction";
import { useSelectedNode } from "./useSelectedNode";
import { extractFeatures } from "../Platform/Hosted/extractFeatures";
export interface CollectionContextMenuButtonParams {
databaseId: string;
@@ -60,6 +61,17 @@ export const createDatabaseContextMenu = (container: Explorer, databaseId: strin
},
];
if (isFabricNative() && !userContext.fabricContext?.isReadOnly) {
const features = extractFeatures();
if (features?.enableRestoreContainer) {
items.push({
iconSrc: AddCollectionIcon,
onClick: () => openRestoreContainerDialog(),
label: `Restore ${getCollectionName()}`,
});
}
}
if (!isFabricNative() && (userContext.apiType !== "Tables" || userContext.features.enableSDKoperations)) {
items.push({
iconSrc: DeleteDatabaseIcon,

View File

@@ -54,6 +54,6 @@
.mainButtonsContainer {
display: flex;
gap: 0 16px;
margin-bottom: 10px
margin: 40px auto
}

View File

@@ -164,6 +164,23 @@ export const SplashScreen: React.FC<SplashScreenProps> = ({ explorer }) => {
const container = explorer;
const subscriptions: Array<{ dispose: () => void }> = [];
let title: string;
let subtitle: string;
switch (userContext.apiType) {
case "Postgres":
title = "Welcome to Azure Cosmos DB for PostgreSQL";
subtitle = "Get started with our sample datasets, documentation, and additional tools.";
break;
case "VCoreMongo":
title = "Welcome to Azure DocumentDB (with MongoDB compatibility)";
subtitle = "Get started with our sample datasets, documentation, and additional tools.";
break;
default:
title = "Welcome to Azure Cosmos DB";
subtitle = "Globally distributed, multi-model database service for any scale";
}
React.useEffect(() => {
subscriptions.push(
{
@@ -902,10 +919,11 @@ export const SplashScreen: React.FC<SplashScreenProps> = ({ explorer }) => {
return (
<div className={styles.splashScreenContainer}>
<div className={styles.splashScreen}>
<h2 className={styles.title} role="heading" aria-label="Welcome to Azure Cosmos DB">
Welcome to Azure Cosmos DB<span className="activePatch"></span>
<h2 className={styles.title} role="heading" aria-label={title}>
{title}
<span className="activePatch"></span>
</h2>
<div className={styles.subtitle}>Globally distributed, multi-model database service for any scale</div>
<div className={styles.subtitle}>{subtitle}</div>
{getSplashScreenButtons()}
{useCarousel.getState().showCoachMark && (
<Coachmark

View File

@@ -105,9 +105,12 @@ const App = (): JSX.Element => {
// Scenario-based health tracking: start ApplicationLoad and complete phases.
const { startScenario, completePhase } = useMetricScenario();
React.useEffect(() => {
startScenario(MetricScenario.ApplicationLoad);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
// Only start scenario after config is initialized to avoid race conditions
// with message handlers that depend on configContext.platform
if (config) {
startScenario(MetricScenario.ApplicationLoad);
}
}, [config, startScenario]);
React.useEffect(() => {
if (explorer) {

View File

@@ -105,6 +105,12 @@ const requestAndStoreAccessToken = async (): Promise<void> => {
});
};
export const openRestoreContainerDialog = (): void => {
if (isFabricNative()) {
sendCachedDataMessage(FabricMessageTypes.RestoreContainer, []);
}
};
/**
* Check token validity and schedule a refresh if necessary
* @param tokenTimestamp

View File

@@ -40,6 +40,7 @@ export type Features = {
readonly disableConnectionStringLogin: boolean;
readonly enableContainerCopy: boolean;
readonly enableCloudShell: boolean;
readonly enableRestoreContainer: boolean; // only for Fabric
// can be set via both flight and feature flag
autoscaleDefault: boolean;
@@ -111,6 +112,7 @@ export function extractFeatures(given = new URLSearchParams(window.location.sear
enablePriorityBasedExecution: "true" === get("enableprioritybasedexecution"),
disableConnectionStringLogin: "true" === get("disableconnectionstringlogin"),
enableContainerCopy: "true" === get("enablecontainercopy"),
enableRestoreContainer: "true" === get("enablerestorecontainer"),
enableCloudShell: true,
};
}

View File

@@ -43,6 +43,7 @@ describe("AuthorizationUtils", () => {
partitionKeyDefault: false,
partitionKeyDefault2: false,
notebooksDownBanner: false,
enableRestoreContainer: false,
},
});
};

View File

@@ -39,6 +39,7 @@ export enum TestAccount {
MongoReadonly = "MongoReadOnly",
Mongo32 = "Mongo32",
SQL = "SQL",
SQL2 = "SQL2",
SQLReadOnly = "SQLReadOnly",
SQLContainerCopyOnly = "SQLContainerCopyOnly",
}
@@ -51,6 +52,7 @@ export const defaultAccounts: Record<TestAccount, string> = {
[TestAccount.MongoReadonly]: "github-e2etests-mongo-readonly",
[TestAccount.Mongo32]: "github-e2etests-mongo32",
[TestAccount.SQL]: "github-e2etests-sql",
[TestAccount.SQL2]: "github-e2etests-sql-2",
[TestAccount.SQLReadOnly]: "github-e2etests-sql-readonly",
[TestAccount.SQLContainerCopyOnly]: "github-e2etests-sql-containercopyonly",
};
@@ -72,6 +74,9 @@ function tryGetStandardName(accountType: TestAccount) {
}
export function getAccountName(accountType: TestAccount) {
if (accountType === TestAccount.SQL2 && !process.env.CI) {
accountType = TestAccount.SQL;
}
return (
process.env[`DE_TEST_ACCOUNT_NAME_${accountType.toLocaleUpperCase()}`] ??
tryGetStandardName(accountType) ??
@@ -101,6 +106,7 @@ export async function getTestExplorerUrl(accountType: TestAccount, options?: Tes
params.set("feature.enableCopilot", "false");
const nosqlRbacToken = process.env.NOSQL_TESTACCOUNT_TOKEN;
const nosql2RbacToken = process.env.NOSQL2_TESTACCOUNT_TOKEN;
const nosqlReadOnlyRbacToken = process.env.NOSQL_READONLY_TESTACCOUNT_TOKEN;
const nosqlContainerCopyRbacToken = process.env.NOSQL_CONTAINERCOPY_TESTACCOUNT_TOKEN;
const tableRbacToken = process.env.TABLE_TESTACCOUNT_TOKEN;
@@ -117,7 +123,12 @@ export async function getTestExplorerUrl(accountType: TestAccount, options?: Tes
params.set("enableaaddataplane", "true");
}
break;
case TestAccount.SQL2:
if (nosql2RbacToken) {
params.set("nosql2RbacToken", nosql2RbacToken);
params.set("enableaaddataplane", "true");
}
break;
case TestAccount.SQLContainerCopyOnly:
if (nosqlContainerCopyRbacToken) {
params.set("nosqlRbacToken", nosqlContainerCopyRbacToken);
@@ -515,14 +526,14 @@ export class DataExplorer {
const containerNode = await this.waitForContainerNode(context.database.id, context.container.id);
await containerNode.expand();
// refresh tree to remove deleted database
const consoleMessages = await this.getNotificationConsoleMessages();
const refreshButton = this.frame.getByTestId("Sidebar/RefreshButton");
await refreshButton.click();
await expect(consoleMessages).toContainText("Successfully refreshed databases", {
timeout: ONE_MINUTE_MS,
});
await this.collapseNotificationConsole();
// // refresh tree to remove deleted database
// const consoleMessages = await this.getNotificationConsoleMessages();
// const refreshButton = this.frame.getByTestId("Sidebar/RefreshButton");
// await refreshButton.click();
// await expect(consoleMessages).toContainText("Successfully refreshed databases", {
// timeout: ONE_MINUTE_MS,
// });
// await this.collapseNotificationConsole();
const scaleAndSettingsButton = this.frame.getByTestId(
`TreeNode:${context.database.id}/${context.container.id}/Scale & Settings`,

View File

@@ -1,258 +1,258 @@
/* 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 } 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 } from "../../testData";
test.describe("Container Copy - Offline Migration", () => {
let page: Page;
let wrapper: Locator;
let panel: Locator;
let frame: Frame;
let expectedJobName: string;
let targetAccountName: string;
let expectedSubscriptionName: string;
let expectedCopyJobNameInitial: string;
// test.describe("Container Copy - Offline Migration", () => {
// let page: Page;
// let wrapper: Locator;
// let panel: Locator;
// let frame: Frame;
// let expectedJobName: string;
// let targetAccountName: string;
// let expectedSubscriptionName: string;
// let expectedCopyJobNameInitial: string;
test.beforeEach("Setup for offline migration test", async ({ browser }) => {
await createMultipleTestContainers({ accountType: TestAccount.SQLContainerCopyOnly, containerCount: 2 });
// test.beforeEach("Setup for offline migration test", async ({ browser }) => {
// 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()}`;
targetAccountName = getAccountName(TestAccount.SQLContainerCopyOnly);
});
// page = await browser.newPage();
// ({ wrapper, frame } = await ContainerCopy.open(page, TestAccount.SQLContainerCopyOnly));
// expectedJobName = `offline_test_job_${Date.now()}`;
// targetAccountName = getAccountName(TestAccount.SQLContainerCopyOnly);
// });
test.afterEach("Cleanup after offline migration test", async () => {
await page.unroute(/.*/, (route) => route.continue());
await page.close();
});
// test.afterEach("Cleanup after offline migration test", async () => {
// await page.unroute(/.*/, (route) => route.continue());
// await page.close();
// });
test("Successfully create and manage offline migration copy job", async () => {
expect(wrapper).not.toBeNull();
await wrapper.locator(".commandBarContainer").waitFor({ state: "visible" });
// test("Successfully create and manage offline migration copy job", async () => {
// 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 = targetAccountName;
expectedSubscriptionName = await subscriptionDropdown.locator("span.ms-Dropdown-title").innerText();
// // Setup subscription and account
// const subscriptionDropdown = panel.getByTestId("subscription-dropdown");
// const expectedAccountName = targetAccountName;
// 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("source-subscription-name")).toHaveText(expectedSubscriptionName);
await expect(previewContainer.getByTestId("source-account-name")).toHaveText(expectedAccountName);
// // Verify job preview details
// const previewContainer = panel.getByTestId("Panel:PreviewCopyJob");
// await expect(previewContainer).toBeVisible();
// await expect(previewContainer.getByTestId("source-subscription-name")).toHaveText(expectedSubscriptionName);
// await expect(previewContainer.getByTestId("source-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({ timeout: 5000 });
// // Verify panel closes and job appears in the list
// await expect(panel).not.toBeVisible({ timeout: 5000 });
const jobsListContainer = wrapper.locator(".CopyJobListContainer .ms-DetailsList-contentWrapper .ms-List-page");
await jobsListContainer.waitFor({ state: "visible", timeout: 5000 });
// const jobsListContainer = wrapper.locator(".CopyJobListContainer .ms-DetailsList-contentWrapper .ms-List-page");
// await jobsListContainer.waitFor({ state: "visible", timeout: 5000 });
const jobItem = jobsListContainer.getByText(validJobName);
await jobItem.waitFor({ state: "visible", timeout: 5000 });
await expect(jobItem).toBeVisible();
});
});
// const jobItem = jobsListContainer.getByText(validJobName);
// await jobItem.waitFor({ state: "visible", timeout: 5000 });
// await expect(jobItem).toBeVisible();
// });
// });

View File

@@ -1,185 +1,185 @@
/* 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 } 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 } from "../../testData";
test.describe("Container Copy - Online Migration", () => {
let page: Page;
let wrapper: Locator;
let panel: Locator;
let frame: Frame;
let targetAccountName: string;
// test.describe("Container Copy - Online Migration", () => {
// let page: Page;
// let wrapper: Locator;
// let panel: Locator;
// let frame: Frame;
// let targetAccountName: string;
test.beforeEach("Setup for online migration test", async ({ browser }) => {
await createMultipleTestContainers({ accountType: TestAccount.SQLContainerCopyOnly, containerCount: 2 });
// test.beforeEach("Setup for online migration test", async ({ browser }) => {
// await createMultipleTestContainers({ accountType: TestAccount.SQLContainerCopyOnly, containerCount: 2 });
page = await browser.newPage();
({ wrapper, frame } = await ContainerCopy.open(page, TestAccount.SQLContainerCopyOnly));
targetAccountName = getAccountName(TestAccount.SQLContainerCopyOnly);
});
// page = await browser.newPage();
// ({ wrapper, frame } = await ContainerCopy.open(page, TestAccount.SQLContainerCopyOnly));
// targetAccountName = getAccountName(TestAccount.SQLContainerCopyOnly);
// });
test.afterEach("Cleanup after online migration test", async () => {
await page.unroute(/.*/, (route) => route.continue());
await page.close();
});
// test.afterEach("Cleanup after online migration test", async () => {
// await page.unroute(/.*/, (route) => route.continue());
// await page.close();
// });
test("Successfully create and manage online migration copy job", async () => {
expect(wrapper).not.toBeNull();
await wrapper.locator(".commandBarContainer").waitFor({ state: "visible" });
// test("Successfully create and manage online migration copy job", async () => {
// 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("source-account-name")).toHaveText(targetAccountName);
// // Verify job preview and create the online migration job
// const previewContainer = panel.getByTestId("Panel:PreviewCopyJob");
// await expect(previewContainer.getByTestId("source-account-name")).toHaveText(targetAccountName);
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,
`${targetAccountName}/dataTransferJobs/${onlineMigrationJobName}`,
"PUT",
);
await copyButton.click();
await page.waitForTimeout(1000); // Reduced wait time
// const copyJobCreationPromise = waitForApiResponse(
// page,
// `${targetAccountName}/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({ timeout: 5000 });
// // Verify panel closes and job appears in the list
// await expect(panel).not.toBeVisible({ timeout: 5000 });
const jobsListContainer = wrapper.locator(".CopyJobListContainer .ms-DetailsList-contentWrapper .ms-List-page");
await jobsListContainer.waitFor({ state: "visible", timeout: 5000 });
// const jobsListContainer = wrapper.locator(".CopyJobListContainer .ms-DetailsList-contentWrapper .ms-List-page");
// await jobsListContainer.waitFor({ state: "visible", timeout: 5000 });
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", timeout: 5000 });
// 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", timeout: 5000 });
// Verify job status changes to queued state
await expect(statusCell).toContainText(/running|queued|pending/i, { timeout: 5000 });
// // Verify job status changes to queued state
// await expect(statusCell).toContainText(/running|queued|pending/i, { timeout: 5000 });
// 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,
`${targetAccountName}/dataTransferJobs/${onlineMigrationJobName}/pause`,
"POST",
);
expect(pauseResponse.ok()).toBe(true);
// const pauseResponse = await waitForApiResponse(
// page,
// `${targetAccountName}/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 });
// });
// });

View File

@@ -136,9 +136,7 @@ test.describe.serial("Upload Item", () => {
if (existsSync(uploadDocumentDirPath)) {
rmdirSync(uploadDocumentDirPath);
}
if (!process.env.CI) {
await context?.dispose();
}
await context?.dispose();
});
test.afterEach("Close Upload Items panel if still open", async () => {

View File

@@ -10,7 +10,7 @@ let CONTAINER_ID: string;
// Set up test database and container with data before all tests
test.beforeAll(async () => {
testContainer = await createTestSQLContainer(true);
testContainer = await createTestSQLContainer({ includeTestData: true });
DATABASE_ID = testContainer.database.id;
CONTAINER_ID = testContainer.container.id;
});

View File

@@ -30,12 +30,9 @@ test.beforeEach("Open new query tab", async ({ page }) => {
await explorer.frame.getByTestId("NotificationConsole/Contents").waitFor();
});
// Delete database only if not running in CI
if (!process.env.CI) {
test.afterAll("Delete Test Database", async () => {
await context?.dispose();
});
}
test.afterAll("Delete Test Database", async () => {
await context?.dispose();
});
test("Query results", async () => {
// Run the query and verify the results

View File

@@ -10,11 +10,13 @@ test.describe("Change Partition Key", () => {
let previousJobName: string | undefined;
test.beforeAll("Create Test Database", async () => {
context = await createTestSQLContainer();
context = await createTestSQLContainer({
testAccount: TestAccount.SQL2,
});
});
test.beforeEach("Open container settings", async ({ page }) => {
explorer = await DataExplorer.open(page, TestAccount.SQL);
explorer = await DataExplorer.open(page, TestAccount.SQL2);
// Click Scale & Settings and open Partition Key tab
await explorer.openScaleAndSettings(context);
@@ -23,12 +25,9 @@ test.describe("Change Partition Key", () => {
await PartitionKeyTab.click();
});
// Delete database only if not running in CI
if (!process.env.CI) {
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 }) => {
await expect(explorer.frame.getByText("/partitionKey")).toBeVisible();

View File

@@ -8,11 +8,13 @@ test.describe("Computed Properties", () => {
let explorer: DataExplorer = null!;
test.beforeAll("Create Test Database", async () => {
context = await createTestSQLContainer();
context = await createTestSQLContainer({
testAccount: TestAccount.SQL2,
});
});
test.beforeEach("Open Settings tab under Scale & Settings", async ({ page }) => {
explorer = await DataExplorer.open(page, TestAccount.SQL);
explorer = await DataExplorer.open(page, TestAccount.SQL2);
const containerNode = await explorer.waitForContainerNode(context.database.id, context.container.id);
await containerNode.expand();
@@ -22,7 +24,7 @@ test.describe("Computed Properties", () => {
await computedPropertiesTab.click();
});
test.afterAll("Delete Test Database", async () => {
test.afterEach("Delete Test Database", async () => {
await context?.dispose();
});

View File

@@ -118,7 +118,5 @@ async function openScaleTab(browser: Browser): Promise<SetupResult> {
}
async function cleanup({ context }: Partial<SetupResult>) {
if (!process.env.CI) {
await context?.dispose();
}
await context?.dispose();
}

View File

@@ -17,12 +17,9 @@ test.describe("Settings under Scale & Settings", () => {
await settingsTab.click();
});
// Delete database only if not running in CI
if (!process.env.CI) {
test.afterAll("Delete Test Database", async () => {
await context?.dispose();
});
}
test.afterEach("Delete Test Database", async () => {
await context?.dispose();
});
test("Update TTL to On (no default)", async () => {
const ttlOnNoDefaultRadioButton = explorer.frame.getByRole("radio", { name: "ttl-on-no-default-option" });

View File

@@ -7,14 +7,16 @@ test.describe("Stored Procedures", () => {
let explorer: DataExplorer = null!;
test.beforeAll("Create Test Database", async () => {
context = await createTestSQLContainer();
context = await createTestSQLContainer({
testAccount: TestAccount.SQL2,
});
});
test.beforeEach("Open container", async ({ page }) => {
explorer = await DataExplorer.open(page, TestAccount.SQL);
explorer = await DataExplorer.open(page, TestAccount.SQL2);
});
test.afterAll("Delete Test Database", async () => {
test.afterEach("Delete Test Database", async () => {
await context?.dispose();
});
@@ -43,7 +45,7 @@ test.describe("Stored Procedures", () => {
);
// Execute stored procedure
const executeButton = explorer.commandBarButton(CommandBarButton.Execute);
const executeButton = explorer.commandBarButton(CommandBarButton.Execute).first();
await executeButton.click();
const executeSidePanelButton = explorer.frame.getByTestId("Panel/OkButton");
await executeSidePanelButton.click();

View File

@@ -19,18 +19,18 @@ test.describe("Triggers", () => {
request.setBody(itemToCreate);
}`;
test.beforeAll("Create Test Database", async () => {
context = await createTestSQLContainer();
context = await createTestSQLContainer({
testAccount: TestAccount.SQL2,
});
});
test.beforeEach("Open container", async ({ page }) => {
explorer = await DataExplorer.open(page, TestAccount.SQL);
explorer = await DataExplorer.open(page, TestAccount.SQL2);
});
if (!process.env.CI) {
test.afterAll("Delete Test Database", async () => {
await context?.dispose();
});
}
test.afterEach("Delete Test Database", async () => {
await context?.dispose();
});
test("Add and delete trigger", async ({ page }, testInfo) => {
// Open container context menu and click New Trigger

View File

@@ -12,18 +12,18 @@ test.describe("User Defined Functions", () => {
}`;
test.beforeAll("Create Test Database", async () => {
context = await createTestSQLContainer();
context = await createTestSQLContainer({
testAccount: TestAccount.SQL2,
});
});
test.beforeEach("Open container", async ({ page }) => {
explorer = await DataExplorer.open(page, TestAccount.SQL);
explorer = await DataExplorer.open(page, TestAccount.SQL2);
});
if (!process.env.CI) {
test.afterAll("Delete Test Database", async () => {
await context?.dispose();
});
}
test.afterEach("Delete Test Database", async () => {
await context?.dispose();
});
test("Add, execute, and delete user defined function", async ({ page }, testInfo) => {
// Open container context menu and click New UDF

View File

@@ -86,13 +86,14 @@ type createTestSqlContainerConfig = {
includeTestData?: boolean;
partitionKey?: string;
databaseName?: string;
testAccount?: TestAccount;
};
type createMultipleTestSqlContainerConfig = {
containerCount?: number;
partitionKey?: string;
databaseName?: string;
accountType: TestAccount.SQLContainerCopyOnly | TestAccount.SQL;
accountType: TestAccount.SQLContainerCopyOnly | TestAccount.SQL | TestAccount.SQL2;
};
export async function createMultipleTestContainers({
@@ -114,12 +115,7 @@ export async function createMultipleTestContainers({
endpoint: account.documentEndpoint!,
};
const rbacToken =
accountType === TestAccount.SQL
? process.env.NOSQL_TESTACCOUNT_TOKEN
: accountType === TestAccount.SQLContainerCopyOnly
? process.env.NOSQL_CONTAINERCOPY_TESTACCOUNT_TOKEN
: "";
const rbacToken = getRbacToken(accountType);
if (rbacToken) {
clientOptions.tokenProvider = async (): Promise<string> => {
const AUTH_PREFIX = `type=aad&ver=1.0&sig=`;
@@ -155,20 +151,21 @@ export async function createTestSQLContainer({
includeTestData = false,
partitionKey = "/partitionKey",
databaseName = "",
testAccount = TestAccount.SQL,
}: createTestSqlContainerConfig = {}) {
const databaseId = databaseName ? databaseName : generateUniqueName("db");
const containerId = "testcontainer"; // A unique container name isn't needed because the database is unique
const credentials = getAzureCLICredentials();
const adaptedCredentials = new AzureIdentityCredentialAdapter(credentials);
const armClient = new CosmosDBManagementClient(adaptedCredentials, subscriptionId);
const accountName = getAccountName(TestAccount.SQL);
const accountName = getAccountName(testAccount);
const account = await armClient.databaseAccounts.get(resourceGroupName, accountName);
const clientOptions: CosmosClientOptions = {
endpoint: account.documentEndpoint!,
};
const nosqlAccountRbacToken = process.env.NOSQL_TESTACCOUNT_TOKEN;
const nosqlAccountRbacToken = getRbacToken(testAccount);
if (nosqlAccountRbacToken) {
clientOptions.tokenProvider = async (): Promise<string> => {
const AUTH_PREFIX = `type=aad&ver=1.0&sig=`;
@@ -252,3 +249,16 @@ export async function retry<T>(fn: () => Promise<T>, retries = 3, delayMs = 1000
}
throw lastError;
}
function getRbacToken(accountType: TestAccount): string | undefined {
switch (accountType) {
case TestAccount.SQL:
return process.env.NOSQL_TESTACCOUNT_TOKEN;
case TestAccount.SQL2:
return process.env.NOSQL2_TESTACCOUNT_TOKEN;
case TestAccount.SQLContainerCopyOnly:
return process.env.NOSQL_CONTAINERCOPY_TESTACCOUNT_TOKEN;
default:
return undefined;
}
}

View File

@@ -17,6 +17,7 @@ const nosqlRbacToken =
urlSearchParams.get("nosqlRbacToken") ||
(enablecontainercopy ? process.env.NOSQL_CONTAINERCOPY_TESTACCOUNT_TOKEN : process.env.NOSQL_TESTACCOUNT_TOKEN) ||
"";
const nosql2RbacToken = urlSearchParams.get("nosql2RbacToken") || process.env.NOSQL2_TESTACCOUNT_TOKEN || "";
const nosqlReadOnlyRbacToken =
urlSearchParams.get("nosqlReadOnlyRbacToken") || process.env.NOSQL_READONLY_TESTACCOUNT_TOKEN || "";
const tableRbacToken = urlSearchParams.get("tableRbacToken") || process.env.TABLE_TESTACCOUNT_TOKEN || "";
@@ -43,6 +44,9 @@ const initTestExplorer = async (): Promise<void> => {
case "sql":
rbacToken = nosqlRbacToken;
break;
case "sql2":
rbacToken = nosql2RbacToken;
break;
case "sql-readonly":
rbacToken = nosqlReadOnlyRbacToken;
break;