mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-06-08 21:47:35 +01:00
Added quantizer type playwright test
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
import { CommandBarButton, DataExplorer, ONE_MINUTE_MS, TestAccount } from "../../../fx";
|
||||
import {
|
||||
CommandBarButton,
|
||||
DataExplorer,
|
||||
getDropdownItemByNameOrPosition,
|
||||
ONE_MINUTE_MS,
|
||||
TestAccount,
|
||||
} from "../../../fx";
|
||||
import { createTestSQLContainer, TestContainerContext } from "../../../testData";
|
||||
|
||||
test.describe("Vector Policy under Scale & Settings", () => {
|
||||
@@ -190,4 +196,119 @@ test.describe("Vector Policy under Scale & Settings", () => {
|
||||
const saveButton = explorer.commandBarButton(CommandBarButton.Save);
|
||||
await expect(saveButton).toBeDisabled();
|
||||
});
|
||||
|
||||
test("Quantizer type dropdown is disabled when index type is none", async () => {
|
||||
const existingCount = await getPolicyCount();
|
||||
|
||||
const addButton = explorer.frame.locator("#add-vector-policy");
|
||||
await addButton.click();
|
||||
|
||||
const newIndex = existingCount + 1;
|
||||
|
||||
const quantizerDropdownBtn = explorer.frame.locator(`#vector-policy-quantizerType-${newIndex}`);
|
||||
await expect(quantizerDropdownBtn).toBeDisabled();
|
||||
});
|
||||
|
||||
test("Quantizer type dropdown is disabled for flat index type", async () => {
|
||||
const existingCount = await getPolicyCount();
|
||||
|
||||
const addButton = explorer.frame.locator("#add-vector-policy");
|
||||
await addButton.click();
|
||||
|
||||
const newIndex = existingCount + 1;
|
||||
|
||||
await explorer.frame.locator(`#vector-policy-indexType-${newIndex}`).click();
|
||||
// Use exact match because "flat" is also a substring of "quantizedFlat".
|
||||
await explorer.frame.getByRole("option", { name: "flat", exact: true }).click();
|
||||
|
||||
const quantizerDropdownBtn = explorer.frame.locator(`#vector-policy-quantizerType-${newIndex}`);
|
||||
await expect(quantizerDropdownBtn).toBeDisabled();
|
||||
});
|
||||
|
||||
test("Quantizer type dropdown becomes enabled and defaults to Product for diskANN index type", async () => {
|
||||
const existingCount = await getPolicyCount();
|
||||
|
||||
const addButton = explorer.frame.locator("#add-vector-policy");
|
||||
await addButton.click();
|
||||
|
||||
const newIndex = existingCount + 1;
|
||||
|
||||
await explorer.frame.locator(`#vector-policy-indexType-${newIndex}`).click();
|
||||
await (await getDropdownItemByNameOrPosition(explorer.frame, { name: "diskANN" })).click();
|
||||
|
||||
const quantizerDropdownBtn = explorer.frame.locator(`#vector-policy-quantizerType-${newIndex}`);
|
||||
await expect(quantizerDropdownBtn).toBeEnabled();
|
||||
await expect(quantizerDropdownBtn).toContainText("Product");
|
||||
});
|
||||
|
||||
test("Quantizer type dropdown becomes enabled and defaults to Product for quantizedFlat index type", async () => {
|
||||
const existingCount = await getPolicyCount();
|
||||
|
||||
const addButton = explorer.frame.locator("#add-vector-policy");
|
||||
await addButton.click();
|
||||
|
||||
const newIndex = existingCount + 1;
|
||||
|
||||
await explorer.frame.locator(`#vector-policy-indexType-${newIndex}`).click();
|
||||
await (await getDropdownItemByNameOrPosition(explorer.frame, { name: "quantizedFlat" })).click();
|
||||
|
||||
const quantizerDropdownBtn = explorer.frame.locator(`#vector-policy-quantizerType-${newIndex}`);
|
||||
await expect(quantizerDropdownBtn).toBeEnabled();
|
||||
await expect(quantizerDropdownBtn).toContainText("Product");
|
||||
});
|
||||
|
||||
test("Quantizer type can be changed to Spherical (Preview)", async () => {
|
||||
const existingCount = await getPolicyCount();
|
||||
|
||||
const addButton = explorer.frame.locator("#add-vector-policy");
|
||||
await addButton.click();
|
||||
|
||||
const newIndex = existingCount + 1;
|
||||
|
||||
await explorer.frame.locator(`#vector-policy-path-${newIndex}`).fill("/embedding");
|
||||
await explorer.frame.locator(`#vector-policy-dimension-${newIndex}`).fill("1536");
|
||||
|
||||
await explorer.frame.locator(`#vector-policy-indexType-${newIndex}`).click();
|
||||
await (await getDropdownItemByNameOrPosition(explorer.frame, { name: "diskANN" })).click();
|
||||
|
||||
const quantizerDropdownBtn = explorer.frame.locator(`#vector-policy-quantizerType-${newIndex}`);
|
||||
await quantizerDropdownBtn.click();
|
||||
await (await getDropdownItemByNameOrPosition(explorer.frame, { position: 1 })).click();
|
||||
|
||||
await expect(quantizerDropdownBtn).not.toContainText("Product");
|
||||
});
|
||||
|
||||
test("Saving a vector policy with diskANN and Spherical quantizer type persists", async () => {
|
||||
const existingCount = await getPolicyCount();
|
||||
|
||||
const addButton = explorer.frame.locator("#add-vector-policy");
|
||||
await addButton.click();
|
||||
|
||||
const newIndex = existingCount + 1;
|
||||
|
||||
await explorer.frame.locator(`#vector-policy-path-${newIndex}`).fill("/vecQuantizer");
|
||||
await explorer.frame.locator(`#vector-policy-dimension-${newIndex}`).fill("1536");
|
||||
|
||||
await explorer.frame.locator(`#vector-policy-indexType-${newIndex}`).click();
|
||||
await (await getDropdownItemByNameOrPosition(explorer.frame, { name: "diskANN" })).click();
|
||||
|
||||
const quantizerDropdownBtn = explorer.frame.locator(`#vector-policy-quantizerType-${newIndex}`);
|
||||
await quantizerDropdownBtn.click();
|
||||
await (await getDropdownItemByNameOrPosition(explorer.frame, { position: 1 })).click();
|
||||
|
||||
// Save
|
||||
const saveButton = explorer.commandBarButton(CommandBarButton.Save);
|
||||
await expect(saveButton).toBeEnabled();
|
||||
await saveButton.click();
|
||||
await expect(explorer.getConsoleHeaderStatus()).toContainText(`${context.container.id}`, {
|
||||
timeout: 2 * ONE_MINUTE_MS,
|
||||
});
|
||||
|
||||
await explorer.openScaleAndSettings(context);
|
||||
await explorer.frame.getByTestId("settings-tab-header/ContainerVectorPolicyTab").click();
|
||||
await explorer.frame.getByRole("tab", { name: "Vector Policy" }).click();
|
||||
|
||||
const savedQuantizerBtn = explorer.frame.locator(`#vector-policy-quantizerType-${newIndex}`);
|
||||
await expect(savedQuantizerBtn).toContainText("Spherical");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user