From 8e879a1d7b26973b91bb5dc67d3baa9dd5bfeccf Mon Sep 17 00:00:00 2001 From: sakshigupta12feb Date: Mon, 6 Apr 2026 21:39:20 +0530 Subject: [PATCH] Removed preview label from DDM (#2442) * Removed preview label from DDM * Fix vector policy Playwright tests to handle shared container state and Node 19+ crypto * fixed lint error * updated lint --------- Co-authored-by: Sakshi Gupta --- .../Controls/Settings/SettingsUtils.test.tsx | 2 +- .../SettingsComponent.test.tsx.snap | 2 +- src/Localization/en/Resources.json | 2 +- .../containerPolicies/vectorPolicy.spec.ts | 135 +++++++++--------- test/testData.ts | 7 +- 5 files changed, 76 insertions(+), 72 deletions(-) diff --git a/src/Explorer/Controls/Settings/SettingsUtils.test.tsx b/src/Explorer/Controls/Settings/SettingsUtils.test.tsx index fbecfb953..ea05388ae 100644 --- a/src/Explorer/Controls/Settings/SettingsUtils.test.tsx +++ b/src/Explorer/Controls/Settings/SettingsUtils.test.tsx @@ -286,7 +286,7 @@ describe("SettingsUtils", () => { expect(getTabTitle(SettingsV2TabTypes.ComputedPropertiesTab)).toBe("Computed Properties"); expect(getTabTitle(SettingsV2TabTypes.ContainerVectorPolicyTab)).toBe("Container Policies"); expect(getTabTitle(SettingsV2TabTypes.ThroughputBucketsTab)).toBe("Throughput Buckets"); - expect(getTabTitle(SettingsV2TabTypes.DataMaskingTab)).toBe("Masking Policy (preview)"); + expect(getTabTitle(SettingsV2TabTypes.DataMaskingTab)).toBe("Masking Policy"); }); it("handles partition key tab title based on fabric native", () => { diff --git a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap index 832ceb7a8..daa26da90 100644 --- a/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap +++ b/src/Explorer/Controls/Settings/__snapshots__/SettingsComponent.test.tsx.snap @@ -615,7 +615,7 @@ exports[`SettingsComponent renders 1`] = ` "data-test": "settings-tab-header/DataMaskingTab", } } - headerText="Masking Policy (preview)" + headerText="Masking Policy" itemKey="DataMaskingTab" key="DataMaskingTab" style={ diff --git a/src/Localization/en/Resources.json b/src/Localization/en/Resources.json index 55a823113..7723aa709 100644 --- a/src/Localization/en/Resources.json +++ b/src/Localization/en/Resources.json @@ -765,7 +765,7 @@ "containerPolicies": "Container Policies", "throughputBuckets": "Throughput Buckets", "globalSecondaryIndexPreview": "Global Secondary Index (Preview)", - "maskingPolicyPreview": "Masking Policy (preview)" + "maskingPolicyPreview": "Masking Policy" }, "mongoNotifications": { "selectTypeWarning": "Please select a type for each index.", diff --git a/test/sql/scaleAndSettings/containerPolicies/vectorPolicy.spec.ts b/test/sql/scaleAndSettings/containerPolicies/vectorPolicy.spec.ts index 001ca4a7b..f1fd4a39a 100644 --- a/test/sql/scaleAndSettings/containerPolicies/vectorPolicy.spec.ts +++ b/test/sql/scaleAndSettings/containerPolicies/vectorPolicy.spec.ts @@ -36,17 +36,57 @@ test.describe("Vector Policy under Scale & Settings", () => { await context?.dispose(); }); + /** Count vector policy entries currently in the DOM. */ + const getPolicyCount = async (): Promise => { + 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 => { + 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(); + + 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; + }; + test("Add new vector embedding policy", async () => { + const existingCount = await getPolicyCount(); + // Click Add vector embedding button const addButton = explorer.frame.locator("#add-vector-policy"); await addButton.click(); + const newIndex = existingCount + 1; + // Fill in path - const pathInput = explorer.frame.locator("#vector-policy-path-1"); + const pathInput = explorer.frame.locator(`#vector-policy-path-${newIndex}`); await pathInput.fill("/embedding"); // Fill in dimensions - const dimensionsInput = explorer.frame.locator("#vector-policy-dimension-1"); + const dimensionsInput = explorer.frame.locator(`#vector-policy-dimension-${newIndex}`); await dimensionsInput.fill("1500"); // Save changes @@ -62,25 +102,8 @@ test.describe("Vector Policy under Scale & Settings", () => { }); test("Existing vector embedding policy fields are disabled", async () => { - // First add a vector embedding policy - const addButton = explorer.frame.locator("#add-vector-policy"); - await addButton.click(); - - const pathInput = explorer.frame.locator("#vector-policy-path-1"); - await pathInput.fill("/existingEmbedding"); - - const dimensionsInput = explorer.frame.locator("#vector-policy-dimension-1"); - await dimensionsInput.fill("700"); - - // Save the policy - 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, - }, - ); + // 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"); @@ -92,28 +115,14 @@ test.describe("Vector Policy under Scale & Settings", () => { }); test("New vector embedding policy fields are enabled while existing are disabled", async () => { - // First, create an existing policy + // 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(); - const firstPathInput = explorer.frame.locator("#vector-policy-path-1"); - await firstPathInput.fill("/existingPolicy"); - - const firstDimensionsInput = explorer.frame.locator("#vector-policy-dimension-1"); - await firstDimensionsInput.fill("500"); - - // Save the policy to make it "existing" - 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, - }, - ); - - // Now add a new policy - await addButton.click(); + const newIndex = existingCount + 1; // Verify the existing policy fields are disabled const existingPathInput = explorer.frame.locator("#vector-policy-path-1"); @@ -122,46 +131,31 @@ test.describe("Vector Policy under Scale & Settings", () => { await expect(existingDimensionsInput).toBeDisabled(); // Verify the new policy fields are enabled - const newPathInput = explorer.frame.locator("#vector-policy-path-2"); - const newDimensionsInput = explorer.frame.locator("#vector-policy-dimension-2"); + 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 () => { - // First add a vector embedding policy - const addButton = explorer.frame.locator("#add-vector-policy"); - await addButton.click(); - - const pathInput = explorer.frame.locator("#vector-policy-path-1"); - await pathInput.fill("/toBeDeleted"); - - const dimensionsInput = explorer.frame.locator("#vector-policy-dimension-1"); - await dimensionsInput.fill("256"); - - // Save the policy - 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, - }, - ); + // 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(); - // Click the delete (trash) button for the vector embedding + // 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 the policy fields are removed - await expect(explorer.frame.locator("#vector-policy-path-1")).not.toBeVisible(); - await expect(explorer.frame.locator("#vector-policy-dimension-1")).not.toBeVisible(); + // 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( @@ -171,16 +165,21 @@ test.describe("Vector Policy under Scale & Settings", () => { }, ); - // Verify the policy is still gone after save - await expect(explorer.frame.locator("#vector-policy-path-1")).not.toBeVisible(); + // Verify the count is still reduced after save + const countAfterSave = await getPolicyCount(); + expect(countAfterSave).toBe(existingCount - 1); }); test("Validation error for empty path", async () => { + const existingCount = await getPolicyCount(); + const addButton = explorer.frame.locator("#add-vector-policy"); await addButton.click(); + const newIndex = existingCount + 1; + // Leave path empty, just fill dimensions - const dimensionsInput = explorer.frame.locator("#vector-policy-dimension-1"); + const dimensionsInput = explorer.frame.locator(`#vector-policy-dimension-${newIndex}`); await dimensionsInput.fill("512"); // Check for validation error on path diff --git a/test/testData.ts b/test/testData.ts index cabb90f32..494ce2e5d 100644 --- a/test/testData.ts +++ b/test/testData.ts @@ -18,7 +18,12 @@ import { subscriptionId, TestAccount, } from "./fx"; -globalThis.crypto = webcrypto as Crypto; + +// In Node.js >= 19, globalThis.crypto is already available as a read-only getter. +// Only assign the polyfill for older versions. +if (!globalThis.crypto) { + Object.defineProperty(globalThis, "crypto", { value: webcrypto, writable: true, configurable: true }); +} export interface TestItem { id: string;