Scope container copy account mocks by phase

This commit is contained in:
Vsevolod Kukol
2026-09-11 23:03:21 +02:00
parent fef218c66b
commit 23e92a3f3a
@@ -102,37 +102,15 @@ test.describe("Container Copy - Permission Screen Verification", () => {
await expect(permissionScreen.getByText("Online container copy", { exact: true })).toBeVisible(); await expect(permissionScreen.getByText("Online container copy", { exact: true })).toBeVisible();
await expect(permissionScreen.getByText("Cross-account container copy", { exact: true })).toBeVisible(); await expect(permissionScreen.getByText("Cross-account container copy", { exact: true })).toBeVisible();
// Mock source account updates and refreshes used by the permission actions. const sourceAccountRoute = `**/Microsoft.DocumentDB/databaseAccounts/${sourceAccountName}**`;
await page.route(`**/Microsoft.DocumentDB/databaseAccounts/${sourceAccountName}**`, async (route) => {
const mockData = { // Keep PITR polling deterministic without changing the source account state.
id: new URL(route.request().url()).pathname, await page.route(sourceAccountRoute, async (route) => {
name: sourceAccountName, if (route.request().method() === "GET" && route.request().url().includes("api-version=2025-05-01-preview")) {
location: "East US",
type: "Microsoft.DocumentDB/databaseAccounts",
kind: "GlobalDocumentDB",
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({ await route.fulfill({
status: 200, status: 200,
contentType: "application/json", contentType: "application/json",
body: JSON.stringify({ status: "Succeeded" }), body: JSON.stringify({ properties: { backupPolicy: { type: "Periodic" } } }),
});
} else if (route.request().method() === "GET") {
await route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify(mockData),
}); });
} else { } else {
await route.continue(); await route.continue();
@@ -180,6 +158,7 @@ test.describe("Container Copy - Permission Screen Verification", () => {
await expect(refreshBtn).toBeVisible({ timeout: 5000 }); await expect(refreshBtn).toBeVisible({ timeout: 5000 });
await expect(pitrBtn).not.toBeVisible(); await expect(pitrBtn).not.toBeVisible();
await page.unroute(sourceAccountRoute);
// Setup additional API mocks for role assignments and permissions // Setup additional API mocks for role assignments and permissions
// In the redesigned flow, role assignments are checked on the SOURCE account (current account = sourceAccountName). // In the redesigned flow, role assignments are checked on the SOURCE account (current account = sourceAccountName).
@@ -217,6 +196,43 @@ test.describe("Container Copy - Permission Screen Verification", () => {
}); });
}); });
// Return the completed identity state only for the managed-identity action.
await page.route(sourceAccountRoute, async (route) => {
const mockData = {
id: new URL(route.request().url()).pathname,
name: sourceAccountName,
location: "East US",
type: "Microsoft.DocumentDB/databaseAccounts",
kind: "GlobalDocumentDB",
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") {
await route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify(mockData),
});
} else {
await route.continue();
}
});
// Verify cross-account permissions functionality // Verify cross-account permissions functionality
const expandedCrossAccordionHeader = permissionScreen const expandedCrossAccordionHeader = permissionScreen
.getByTestId("permission-group-container-crossAccountConfigs") .getByTestId("permission-group-container-crossAccountConfigs")