Compare commits

..

3 Commits

Author SHA1 Message Date
sakshigupta12feb
6c2ce9362c Merge branch 'master' into users/sakshig/testIndexingPolicy 2026-02-16 16:22:52 +05:30
sakshigupta12feb
2a20076200 Merge branch 'master' into users/sakshig/testIndexingPolicy 2026-02-02 14:08:23 +05:30
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
7 changed files with 193 additions and 53 deletions

View File

@@ -6,7 +6,7 @@ import { MinimalQueryIterator, nextPage } from "../IteratorUtilities";
// Redact sensitive information from BadRequest errors with specific codes
export const redactSyntaxErrorMessage = (error: unknown): unknown => {
const codesToRedact = ["SC1001", "SC2001", "SC1010"];
const codesToRedact = ["SC1001", "SC2001"];
try {
// Handle error objects with a message property

View File

@@ -543,6 +543,9 @@ export class ThroughputInputAutoPilotV3Component extends React.Component<
<span style={{ float: "left", transform: "translateX(-50%)" }}>
{this.props.instantMaximumThroughput.toLocaleString(ThroughputInputAutoPilotV3Component.LOCALE_EN_US)}
</span>
<span style={{ float: "right" }}>
{this.props.softAllowedMaximumThroughput.toLocaleString(ThroughputInputAutoPilotV3Component.LOCALE_EN_US)}
</span>
<span style={{ float: "right" }} data-test="soft-allowed-maximum-throughput">
{this.props.softAllowedMaximumThroughput.toLocaleString(ThroughputInputAutoPilotV3Component.LOCALE_EN_US)}
</span>

View File

@@ -426,6 +426,15 @@ exports[`ThroughputInputAutoPilotV3Component autopilot input visible 1`] = `
>
5,000
</span>
<span
style={
{
"float": "right",
}
}
>
1,000,000
</span>
<span
data-test="soft-allowed-maximum-throughput"
style={
@@ -1025,6 +1034,15 @@ exports[`ThroughputInputAutoPilotV3Component spendAck checkbox visible 1`] = `
>
5,000
</span>
<span
style={
{
"float": "right",
}
}
>
1,000,000
</span>
<span
data-test="soft-allowed-maximum-throughput"
style={
@@ -1602,6 +1620,15 @@ exports[`ThroughputInputAutoPilotV3Component throughput input visible 1`] = `
>
5,000
</span>
<span
style={
{
"float": "right",
}
}
>
1,000,000
</span>
<span
data-test="soft-allowed-maximum-throughput"
style={

View File

@@ -120,7 +120,7 @@ const App = (): JSX.Element => {
}, [explorer]);
// Track interactive phase for both ContainerCopyPanel and DivExplorer paths
useInteractive(MetricScenario.ApplicationLoad, !!config);
useInteractive(MetricScenario.ApplicationLoad);
if (!explorer) {
return <LoadingExplorer />;

View File

@@ -56,13 +56,6 @@ class ScenarioMonitor {
});
}
private devLog(msg: string) {
if (process.env.NODE_ENV === "development") {
// eslint-disable-next-line no-console
console.log(`[Metrics] ${msg}`);
}
}
start(scenario: MetricScenario) {
if (this.contexts.has(scenario)) {
return;
@@ -93,10 +86,6 @@ class ScenarioMonitor {
ctx.phases.set(phase, { startMarkName: phaseStartMarkName });
});
this.devLog(
`scenario_start: ${scenario} | phases=${config.requiredPhases.join(", ")} | timeout=${config.timeoutMs}ms`,
);
traceMark(Action.MetricsScenario, {
event: "scenario_start",
scenario,
@@ -147,12 +136,6 @@ class ScenarioMonitor {
const endTimeISO = endEntry ? new Date(navigationStart + endEntry.startTime).toISOString() : undefined;
const durationMs = startEntry && endEntry ? endEntry.startTime - startEntry.startTime : undefined;
this.devLog(
`phase_complete: ${scenario}.${phase} | ${
durationMs !== null && durationMs !== undefined ? `${Math.round(durationMs)}ms` : "?"
} | ${ctx.completed.size}/${ctx.config.requiredPhases.length} phases`,
);
traceSuccess(Action.MetricsScenario, {
event: "phase_complete",
scenario,
@@ -172,13 +155,6 @@ class ScenarioMonitor {
return;
}
// If an expected failure was flagged (auth, firewall, etc.), treat as success.
if (ctx.hasExpectedFailure) {
this.devLog(`phase_fail: ${scenario}.${phase} — expected failure, completing as healthy`);
this.completePhase(scenario, phase);
return;
}
// Mark the explicitly failed phase
performance.mark(`scenario_${scenario}_${phase}_failed`);
ctx.failed.add(phase);
@@ -193,12 +169,6 @@ class ScenarioMonitor {
// Build a snapshot with failure info
const failureSnapshot = this.buildSnapshot(ctx, { final: false, timedOut: false });
this.devLog(
`phase_fail: ${scenario}.${phase} | failed=[${Array.from(ctx.failed).join(", ")}] | completed=[${Array.from(
ctx.completed,
).join(", ")}]`,
);
traceFailure(Action.MetricsScenario, {
event: "phase_fail",
scenario,
@@ -207,7 +177,7 @@ class ScenarioMonitor {
completedPhases: Array.from(ctx.completed).join(","),
});
// Emit unhealthy immediately for unexpected failures
// Emit unhealthy immediately
this.emit(ctx, false, false, failureSnapshot);
}
@@ -300,19 +270,6 @@ class ScenarioMonitor {
ttfb: finalSnapshot.vitals?.ttfb,
});
this.devLog(
`scenario_end: ${ctx.scenario} | ${healthy ? "healthy" : "unhealthy"} | ${
timedOut ? "timed out" : `${Math.round(finalSnapshot.durationMs)}ms`
} | ${JSON.stringify({
completedPhases: finalSnapshot.completed.join(", "),
failedPhases: finalSnapshot.failedPhases?.join(", ") || "none",
platform,
api,
phaseTimings: finalSnapshot.phaseTimings,
vitals: finalSnapshot.vitals,
})}`,
);
// Call portal backend health metrics endpoint
// If healthy is true (either completed successfully or timeout with expected failure), report healthy
if (healthy) {

View File

@@ -7,18 +7,14 @@ import { ApplicationMetricPhase, CommonMetricPhase } from "./ScenarioConfig";
* Hook to automatically complete the Interactive phase when the component becomes interactive.
* Uses requestAnimationFrame to complete after the browser has painted.
*/
export function useInteractive(scenario: MetricScenario, enabled = true) {
export function useInteractive(scenario: MetricScenario) {
const { completePhase } = useMetricScenario();
React.useEffect(() => {
if (!enabled) {
return undefined;
}
const id = requestAnimationFrame(() => {
requestAnimationFrame(() => {
completePhase(scenario, CommonMetricPhase.Interactive);
});
return () => cancelAnimationFrame(id);
}, [scenario, completePhase, enabled]);
}, [scenario, completePhase]);
}
/**

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,
},
);
});
});