Compare commits

..

1 Commits

Author SHA1 Message Date
Copilot
4c9dea0913 Add Playwright E2E tests for Indexing Policy (#2358)
* Initial plan

* Add Playwright test for Indexing Policy

Co-authored-by: sakshigupta12feb <206070758+sakshigupta12feb@users.noreply.github.com>

* Refactor Indexing Policy test to use Editor helper class

Co-authored-by: sakshigupta12feb <206070758+sakshigupta12feb@users.noreply.github.com>

* Address code review feedback - add helper function and improve editor handling

Co-authored-by: sakshigupta12feb <206070758+sakshigupta12feb@users.noreply.github.com>

* Further simplify code by using helper function consistently

Co-authored-by: sakshigupta12feb <206070758+sakshigupta12feb@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sakshigupta12feb <206070758+sakshigupta12feb@users.noreply.github.com>
2026-01-27 21:50:07 +05:30
3 changed files with 170 additions and 16 deletions

27
package-lock.json generated
View File

@@ -125,7 +125,7 @@
"@babel/preset-env": "7.24.7",
"@babel/preset-react": "7.24.7",
"@babel/preset-typescript": "7.24.7",
"@playwright/test": "1.58.0",
"@playwright/test": "1.49.1",
"@testing-library/react": "11.2.3",
"@types/applicationinsights-js": "1.0.7",
"@types/codemirror": "0.0.56",
@@ -10321,13 +10321,12 @@
}
},
"node_modules/@playwright/test": {
"version": "1.58.0",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.58.0.tgz",
"integrity": "sha512-fWza+Lpbj6SkQKCrU6si4iu+fD2dD3gxNHFhUPxsfXBPhnv3rRSQVd0NtBUT9Z/RhF/boCBcuUaMUSTRTopjZg==",
"version": "1.49.1",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.49.1.tgz",
"integrity": "sha512-Ky+BVzPz8pL6PQxHqNRW1k3mIyv933LML7HktS8uik0bUXNCdPhoS/kLihiO1tMf/egaJb4IutXd7UywvXEW+g==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"playwright": "1.58.0"
"playwright": "1.49.1"
},
"bin": {
"playwright": "cli.js"
@@ -30904,13 +30903,12 @@
}
},
"node_modules/playwright": {
"version": "1.58.0",
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.58.0.tgz",
"integrity": "sha512-2SVA0sbPktiIY/MCOPX8e86ehA/e+tDNq+e5Y8qjKYti2Z/JG7xnronT/TXTIkKbYGWlCbuucZ6dziEgkoEjQQ==",
"version": "1.49.1",
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.49.1.tgz",
"integrity": "sha512-VYL8zLoNTBxVOrJBbDuRgDWa3i+mfQgDTrL8Ah9QXZ7ax4Dsj0MSq5bYgytRnDVVe+njoKnfsYkH3HzqVj5UZA==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"playwright-core": "1.58.0"
"playwright-core": "1.49.1"
},
"bin": {
"playwright": "cli.js"
@@ -30923,11 +30921,10 @@
}
},
"node_modules/playwright-core": {
"version": "1.58.0",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.58.0.tgz",
"integrity": "sha512-aaoB1RWrdNi3//rOeKuMiS65UCcgOVljU46At6eFcOFPFHWtd2weHRRow6z/n+Lec0Lvu0k9ZPKJSjPugikirw==",
"version": "1.49.1",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.49.1.tgz",
"integrity": "sha512-BzmpVcs4kE2CH15rWfzpjzVGhWERJfmnXmniSyKeRZUs9Ws65m+RGIi7mjJK/euCegfn3i7jvqWeWyHe9y3Vgg==",
"dev": true,
"license": "Apache-2.0",
"bin": {
"playwright-core": "cli.js"
},

View File

@@ -120,7 +120,7 @@
"@babel/preset-env": "7.24.7",
"@babel/preset-react": "7.24.7",
"@babel/preset-typescript": "7.24.7",
"@playwright/test": "1.58.0",
"@playwright/test": "1.49.1",
"@testing-library/react": "11.2.3",
"@types/applicationinsights-js": "1.0.7",
"@types/codemirror": "0.0.56",

View File

@@ -0,0 +1,157 @@
import { expect, test } from "@playwright/test";
import { CommandBarButton, DataExplorer, Editor, ONE_MINUTE_MS, TestAccount } from "../../fx";
import { createTestSQLContainer, TestContainerContext } from "../../testData";
test.describe("Indexing Policy under Scale & Settings", () => {
let context: TestContainerContext = null!;
let explorer: DataExplorer = null!;
// Helper function to get the indexing policy editor
const getIndexingPolicyEditor = (): Editor => {
const editorContainer = explorer.frame.locator(".settingsV2Editor");
return new Editor(explorer.frame, editorContainer);
};
test.beforeAll("Create Test Database & Open Indexing Policy tab", async ({ browser }) => {
context = await createTestSQLContainer();
const page = await browser.newPage();
explorer = await DataExplorer.open(page, TestAccount.SQL);
// Click Scale & Settings and open Indexing Policy tab
await explorer.openScaleAndSettings(context);
const indexingPolicyTab = explorer.frame.getByTestId("settings-tab-header/IndexingPolicyTab");
await indexingPolicyTab.click();
});
test.afterAll("Delete Test Database", async () => {
await context?.dispose();
});
test("Verify Indexing Policy tab is visible", async () => {
const indexingPolicyTab = explorer.frame.getByTestId("settings-tab-header/IndexingPolicyTab");
await expect(indexingPolicyTab).toBeVisible();
});
test("Verify Indexing Policy editor is present", async () => {
// The Monaco editor is rendered in a div with class settingsV2Editor
const editorContainer = explorer.frame.locator(".settingsV2Editor");
await expect(editorContainer).toBeVisible();
// Verify the editor has content (default indexing policy) using Editor helper
const editor = getIndexingPolicyEditor();
const editorContent = await editor.text();
expect(editorContent).toBeTruthy();
});
test("Update Indexing Policy - Change automatic to false", async () => {
// Use helper function to get editor instance
const editor = getIndexingPolicyEditor();
// Verify the Monaco editor is visible
const editorElement = explorer.frame.locator(".settingsV2Editor").locator(".monaco-editor");
await expect(editorElement).toBeVisible();
// Get current indexing policy content
const currentContent = await editor.text();
expect(currentContent).toBeTruthy();
const indexingPolicy = JSON.parse(currentContent as string);
// Verify default policy structure
expect(indexingPolicy).toHaveProperty("automatic");
expect(indexingPolicy).toHaveProperty("indexingMode");
// Modify the indexing policy - change automatic to false
indexingPolicy.automatic = false;
const updatedContent = JSON.stringify(indexingPolicy, null, 4);
// Set the new content in the editor
await editor.setText(updatedContent);
// Verify the warning message appears for unsaved changes
const warningMessage = explorer.frame.locator(".ms-MessageBar--warning");
await expect(warningMessage).toBeVisible({ timeout: 5000 });
// Save the changes
await explorer.commandBarButton(CommandBarButton.Save).click();
// Verify success message
await expect(explorer.getConsoleHeaderStatus()).toContainText(
`Successfully updated container ${context.container.id}`,
{
timeout: 2 * ONE_MINUTE_MS,
},
);
// Verify warning message is no longer visible after save
await expect(warningMessage).not.toBeVisible({ timeout: 5000 });
});
test("Update Indexing Policy - Change indexingMode to lazy", async () => {
// Use helper function to get editor instance
const editor = getIndexingPolicyEditor();
// Verify the Monaco editor is visible
const editorElement = explorer.frame.locator(".settingsV2Editor").locator(".monaco-editor");
await expect(editorElement).toBeVisible();
// Get current indexing policy content
const currentContent = await editor.text();
expect(currentContent).toBeTruthy();
const indexingPolicy = JSON.parse(currentContent as string);
// Modify the indexing policy - change indexingMode to lazy
indexingPolicy.indexingMode = "lazy";
const updatedContent = JSON.stringify(indexingPolicy, null, 4);
// Set the new content in the editor
await editor.setText(updatedContent);
// Verify the warning message appears
const warningMessage = explorer.frame.locator(".ms-MessageBar--warning");
await expect(warningMessage).toBeVisible({ timeout: 5000 });
// Save the changes
await explorer.commandBarButton(CommandBarButton.Save).click();
// Verify success message
await expect(explorer.getConsoleHeaderStatus()).toContainText(
`Successfully updated container ${context.container.id}`,
{
timeout: 2 * ONE_MINUTE_MS,
},
);
});
test("Update Indexing Policy - Revert automatic to true", async () => {
// Use helper function to get editor instance
const editor = getIndexingPolicyEditor();
// Verify the Monaco editor is visible
const editorElement = explorer.frame.locator(".settingsV2Editor").locator(".monaco-editor");
await expect(editorElement).toBeVisible();
// Get current indexing policy content
const currentContent = await editor.text();
expect(currentContent).toBeTruthy();
const indexingPolicy = JSON.parse(currentContent as string);
// Revert the changes - set automatic back to true and indexingMode to consistent
indexingPolicy.automatic = true;
indexingPolicy.indexingMode = "consistent";
const updatedContent = JSON.stringify(indexingPolicy, null, 4);
// Set the new content in the editor
await editor.setText(updatedContent);
// Save the changes
await explorer.commandBarButton(CommandBarButton.Save).click();
// Verify success message
await expect(explorer.getConsoleHeaderStatus()).toContainText(
`Successfully updated container ${context.container.id}`,
{
timeout: 2 * ONE_MINUTE_MS,
},
);
});
});