mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-06-08 13:37:29 +01:00
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 <sakshig@microsoft.com>
This commit is contained in:
@@ -286,7 +286,7 @@ describe("SettingsUtils", () => {
|
|||||||
expect(getTabTitle(SettingsV2TabTypes.ComputedPropertiesTab)).toBe("Computed Properties");
|
expect(getTabTitle(SettingsV2TabTypes.ComputedPropertiesTab)).toBe("Computed Properties");
|
||||||
expect(getTabTitle(SettingsV2TabTypes.ContainerVectorPolicyTab)).toBe("Container Policies");
|
expect(getTabTitle(SettingsV2TabTypes.ContainerVectorPolicyTab)).toBe("Container Policies");
|
||||||
expect(getTabTitle(SettingsV2TabTypes.ThroughputBucketsTab)).toBe("Throughput Buckets");
|
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", () => {
|
it("handles partition key tab title based on fabric native", () => {
|
||||||
|
|||||||
@@ -615,7 +615,7 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"data-test": "settings-tab-header/DataMaskingTab",
|
"data-test": "settings-tab-header/DataMaskingTab",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
headerText="Masking Policy (preview)"
|
headerText="Masking Policy"
|
||||||
itemKey="DataMaskingTab"
|
itemKey="DataMaskingTab"
|
||||||
key="DataMaskingTab"
|
key="DataMaskingTab"
|
||||||
style={
|
style={
|
||||||
|
|||||||
@@ -765,7 +765,7 @@
|
|||||||
"containerPolicies": "Container Policies",
|
"containerPolicies": "Container Policies",
|
||||||
"throughputBuckets": "Throughput Buckets",
|
"throughputBuckets": "Throughput Buckets",
|
||||||
"globalSecondaryIndexPreview": "Global Secondary Index (Preview)",
|
"globalSecondaryIndexPreview": "Global Secondary Index (Preview)",
|
||||||
"maskingPolicyPreview": "Masking Policy (preview)"
|
"maskingPolicyPreview": "Masking Policy"
|
||||||
},
|
},
|
||||||
"mongoNotifications": {
|
"mongoNotifications": {
|
||||||
"selectTypeWarning": "Please select a type for each index.",
|
"selectTypeWarning": "Please select a type for each index.",
|
||||||
|
|||||||
@@ -36,17 +36,57 @@ test.describe("Vector Policy under Scale & Settings", () => {
|
|||||||
await context?.dispose();
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
|
||||||
|
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 () => {
|
test("Add new vector embedding policy", async () => {
|
||||||
|
const existingCount = await getPolicyCount();
|
||||||
|
|
||||||
// Click Add vector embedding button
|
// Click Add vector embedding button
|
||||||
const addButton = explorer.frame.locator("#add-vector-policy");
|
const addButton = explorer.frame.locator("#add-vector-policy");
|
||||||
await addButton.click();
|
await addButton.click();
|
||||||
|
|
||||||
|
const newIndex = existingCount + 1;
|
||||||
|
|
||||||
// Fill in path
|
// 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");
|
await pathInput.fill("/embedding");
|
||||||
|
|
||||||
// Fill in dimensions
|
// 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");
|
await dimensionsInput.fill("1500");
|
||||||
|
|
||||||
// Save changes
|
// Save changes
|
||||||
@@ -62,25 +102,8 @@ test.describe("Vector Policy under Scale & Settings", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("Existing vector embedding policy fields are disabled", async () => {
|
test("Existing vector embedding policy fields are disabled", async () => {
|
||||||
// First add a vector embedding policy
|
// Ensure there is at least one saved policy
|
||||||
const addButton = explorer.frame.locator("#add-vector-policy");
|
await ensureExistingPolicy();
|
||||||
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,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// Verify the path field is disabled for the existing policy
|
// Verify the path field is disabled for the existing policy
|
||||||
const existingPathInput = explorer.frame.locator("#vector-policy-path-1");
|
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 () => {
|
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");
|
const addButton = explorer.frame.locator("#add-vector-policy");
|
||||||
await addButton.click();
|
await addButton.click();
|
||||||
|
|
||||||
const firstPathInput = explorer.frame.locator("#vector-policy-path-1");
|
const newIndex = existingCount + 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();
|
|
||||||
|
|
||||||
// Verify the existing policy fields are disabled
|
// Verify the existing policy fields are disabled
|
||||||
const existingPathInput = explorer.frame.locator("#vector-policy-path-1");
|
const existingPathInput = explorer.frame.locator("#vector-policy-path-1");
|
||||||
@@ -122,46 +131,31 @@ test.describe("Vector Policy under Scale & Settings", () => {
|
|||||||
await expect(existingDimensionsInput).toBeDisabled();
|
await expect(existingDimensionsInput).toBeDisabled();
|
||||||
|
|
||||||
// Verify the new policy fields are enabled
|
// Verify the new policy fields are enabled
|
||||||
const newPathInput = explorer.frame.locator("#vector-policy-path-2");
|
const newPathInput = explorer.frame.locator(`#vector-policy-path-${newIndex}`);
|
||||||
const newDimensionsInput = explorer.frame.locator("#vector-policy-dimension-2");
|
const newDimensionsInput = explorer.frame.locator(`#vector-policy-dimension-${newIndex}`);
|
||||||
await expect(newPathInput).toBeEnabled();
|
await expect(newPathInput).toBeEnabled();
|
||||||
await expect(newDimensionsInput).toBeEnabled();
|
await expect(newDimensionsInput).toBeEnabled();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Delete existing vector embedding policy", async () => {
|
test("Delete existing vector embedding policy", async () => {
|
||||||
// First add a vector embedding policy
|
// Ensure there is at least one saved policy to delete
|
||||||
const addButton = explorer.frame.locator("#add-vector-policy");
|
const existingCount = await ensureExistingPolicy();
|
||||||
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,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// Verify the policy exists
|
// Verify the policy exists
|
||||||
|
const pathInput = explorer.frame.locator("#vector-policy-path-1");
|
||||||
await expect(pathInput).toBeVisible();
|
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");
|
const deleteButton = explorer.frame.locator("#delete-Vector-embedding-1");
|
||||||
await expect(deleteButton).toBeEnabled();
|
await expect(deleteButton).toBeEnabled();
|
||||||
await deleteButton.click();
|
await deleteButton.click();
|
||||||
|
|
||||||
// Verify the policy fields are removed
|
// Verify one fewer policy entry in the UI
|
||||||
await expect(explorer.frame.locator("#vector-policy-path-1")).not.toBeVisible();
|
const countAfterDelete = await getPolicyCount();
|
||||||
await expect(explorer.frame.locator("#vector-policy-dimension-1")).not.toBeVisible();
|
expect(countAfterDelete).toBe(existingCount - 1);
|
||||||
|
|
||||||
// Save the deletion
|
// Save the deletion
|
||||||
|
const saveButton = explorer.commandBarButton(CommandBarButton.Save);
|
||||||
await expect(saveButton).toBeEnabled();
|
await expect(saveButton).toBeEnabled();
|
||||||
await saveButton.click();
|
await saveButton.click();
|
||||||
await expect(explorer.getConsoleHeaderStatus()).toContainText(
|
await expect(explorer.getConsoleHeaderStatus()).toContainText(
|
||||||
@@ -171,16 +165,21 @@ test.describe("Vector Policy under Scale & Settings", () => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// Verify the policy is still gone after save
|
// Verify the count is still reduced after save
|
||||||
await expect(explorer.frame.locator("#vector-policy-path-1")).not.toBeVisible();
|
const countAfterSave = await getPolicyCount();
|
||||||
|
expect(countAfterSave).toBe(existingCount - 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Validation error for empty path", async () => {
|
test("Validation error for empty path", async () => {
|
||||||
|
const existingCount = await getPolicyCount();
|
||||||
|
|
||||||
const addButton = explorer.frame.locator("#add-vector-policy");
|
const addButton = explorer.frame.locator("#add-vector-policy");
|
||||||
await addButton.click();
|
await addButton.click();
|
||||||
|
|
||||||
|
const newIndex = existingCount + 1;
|
||||||
|
|
||||||
// Leave path empty, just fill dimensions
|
// 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");
|
await dimensionsInput.fill("512");
|
||||||
|
|
||||||
// Check for validation error on path
|
// Check for validation error on path
|
||||||
|
|||||||
+6
-1
@@ -18,7 +18,12 @@ import {
|
|||||||
subscriptionId,
|
subscriptionId,
|
||||||
TestAccount,
|
TestAccount,
|
||||||
} from "./fx";
|
} 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 {
|
export interface TestItem {
|
||||||
id: string;
|
id: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user