🙌 OpenHands: AI-Driven Development
test(snapshot): batch 2 — secrets, verification/condenser, sidebar (12 tests, 12 baselines) (#441)
Rohit Malhotra0f6bfe7b42c6
diff --git a/AGENTS.md b/AGENTS.mdindex 48b4d23fa5..b2131ddfc7 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -31,6 +31,9 @@- Use `dismissConsentModal(page)` after navigation to dismiss the analytics modal.- Use `animations: "disabled"` and `maxDiffPixelRatio: 0.01` in `toHaveScreenshot()` to reduce flakiness.- Target specific elements via `page.getByTestId()` rather than full-page screenshots when possible.+ - **Hidden checkbox pattern**: `SettingsSwitch` renders `<input hidden data-testid="...">`. Both `toBeVisible()` and `click({ force: true })` fail on hidden inputs (no layout dimensions). Use the enclosing `<label>`: `page.locator('label:has([data-testid="my-toggle"])').click()` — the browser's label→control activation fires `onChange` on the hidden input.+ - **HeroUI Autocomplete testId forwarding**: `Autocomplete` does NOT forward `data-testid` to any DOM element. Use `getByRole("combobox", { name: /label text/ })` to locate/assert on dropdown fields generated by `SchemaField`.+ - **SdkSectionPage early return**: `SdkSectionPage` returns a plain `<p>` (no `data-testid` wrapper) when `filteredSchema.sections.length === 0`. Always ensure the mock schema includes the section the page requests. The condenser section is in `agent_settings_schema` (default source), not `conversation_settings_schema`.- **Composing tests**: Use `test.step()` for iterative snapshots within a single test, or extract helper functions (like `navigateToSettings(page)`) to share setup across tests. For heavier reuse, use Playwright fixtures via `test.extend()`.- Snapshots are organized by `{snapshotDir}/{testFilePath}/{projectName}/{arg}.png` (configured in `playwright.config.ts`).- **Conversation page snapshot tests**: The dev server uses MSW service workers for API mocking. For conversation-page tests, rely on MSW's pre-defined mock conversations (IDs "1", "2", "3" in `src/mocks/conversation-handlers.ts`) rather than fighting Playwright route interception. MSW's service worker intercepts requests before Playwright `page.route()` can; Playwright route interceptors only see requests that escape the service worker. Stub WebSocket via `page.addInitScript()` and inject events into the Zustand store via the exposed `window.__OH_EVENT_STORE__` API. Use `test.describe.configure({ mode: "serial" })` for conversation tests since the WebSocket stub + heavier page setup can cause intermittent failures in parallel mode.diff --git a/src/mocks/settings-handlers.ts b/src/mocks/settings-handlers.tsindex f8f0667c64..5fb15b6781 100644--- a/src/mocks/settings-handlers.ts+++ b/src/mocks/settings-handlers.ts@@ -167,6 +167,42 @@ const MOCK_AGENT_SETTINGS_SCHEMA: NonNullable<},],},+ {+ key: "condenser",+ label: "Condenser",+ fields: [+ {+ description:+ "Enable the default LLM-based condenser to summarize long conversation histories.",+ key: "condenser.enable_default_condenser",+ label: "Enable default condenser",+ section: "condenser",+ section_label: "Condenser",+ value_type: "boolean",+ default: true,+ choices: [],+ depends_on: [],+ prominence: "critical",+ secret: false,+ required: true,+ },+ {+ description:+ "Maximum number of tokens the condenser keeps after summarization. Leave blank for unlimited.",+ key: "condenser.condenser_max_size",+ label: "Condenser max size",+ section: "condenser",+ section_label: "Condenser",+ value_type: "integer",+ default: null,+ choices: [],+ depends_on: [],+ prominence: "major",+ secret: false,+ required: false,+ },+ ],+ },],};@@ -256,6 +292,10 @@ export const MOCK_DEFAULT_USER_SETTINGS: Settings = {api_key: null,model: DEFAULT_MODEL,},+ condenser: {+ enable_default_condenser: true,+ condenser_max_size: null,+ },},conversation_settings_schema: MOCK_CONVERSATION_SETTINGS_SCHEMA,conversation_settings: {diff --git a/tests/e2e/__snapshots__/snapshots/settings-secrets.snapshot.spec.ts/chromium/secrets-add-form-filled.png b/tests/e2e/__snapshots__/snapshots/settings-secrets.snapshot.spec.ts/chromium/secrets-add-form-filled.pngnew file mode 100644index 0000000000..6c29924f47Binary files /dev/null and b/tests/e2e/__snapshots__/snapshots/settings-secrets.snapshot.spec.ts/chromium/secrets-add-form-filled.png differdiff --git a/tests/e2e/__snapshots__/snapshots/settings-secrets.snapshot.spec.ts/chromium/secrets-add-form.png b/tests/e2e/__snapshots__/snapshots/settings-secrets.snapshot.spec.ts/chromium/secrets-add-form.pngnew file mode 100644index 0000000000..50e03c8e9cBinary files /dev/null and b/tests/e2e/__snapshots__/snapshots/settings-secrets.snapshot.spec.ts/chromium/secrets-add-form.png differdiff --git a/tests/e2e/__snapshots__/snapshots/settings-secrets.snapshot.spec.ts/chromium/secrets-after-save.png b/tests/e2e/__snapshots__/snapshots/settings-secrets.snapshot.spec.ts/chromium/secrets-after-save.pngnew file mode 100644index 0000000000..71ddbc4dddBinary files /dev/null and b/tests/e2e/__snapshots__/snapshots/settings-secrets.snapshot.spec.ts/chromium/secrets-after-save.png differdiff --git a/tests/e2e/__snapshots__/snapshots/settings-secrets.snapshot.spec.ts/chromium/secrets-delete-confirm.png b/tests/e2e/__snapshots__/snapshots/settings-secrets.snapshot.spec.ts/chromium/secrets-delete-confirm.pngnew file mode 100644index 0000000000..713010955dBinary files /dev/null and b/tests/e2e/__snapshots__/snapshots/settings-secrets.snapshot.spec.ts/chromium/secrets-delete-confirm.png differdiff --git a/tests/e2e/__snapshots__/snapshots/settings-secrets.snapshot.spec.ts/chromium/secrets-list.png b/tests/e2e/__snapshots__/snapshots/settings-secrets.snapshot.spec.ts/chromium/secrets-list.pngnew file mode 100644index 0000000000..ac6c46dee5Binary files /dev/null and b/tests/e2e/__snapshots__/snapshots/settings-secrets.snapshot.spec.ts/chromium/secrets-list.png differdiff --git a/tests/e2e/__snapshots__/snapshots/settings-verification.snapshot.spec.ts/chromium/condenser-settings.png b/tests/e2e/__snapshots__/snapshots/settings-verification.snapshot.spec.ts/chromium/condenser-settings.pngnew file mode 100644index 0000000000..9120bc2a05Binary files /dev/null and b/tests/e2e/__snapshots__/snapshots/settings-verification.snapshot.spec.ts/chromium/condenser-settings.png differdiff --git a/tests/e2e/__snapshots__/snapshots/settings-verification.snapshot.spec.ts/chromium/verification-settings-off.png b/tests/e2e/__snapshots__/snapshots/settings-verification.snapshot.spec.ts/chromium/verification-settings-off.pngnew file mode 100644index 0000000000..43447f44c0Binary files /dev/null and b/tests/e2e/__snapshots__/snapshots/settings-verification.snapshot.spec.ts/chromium/verification-settings-off.png differdiff --git a/tests/e2e/__snapshots__/snapshots/settings-verification.snapshot.spec.ts/chromium/verification-settings-on.png b/tests/e2e/__snapshots__/snapshots/settings-verification.snapshot.spec.ts/chromium/verification-settings-on.pngnew file mode 100644index 0000000000..36b3752534Binary files /dev/null and b/tests/e2e/__snapshots__/snapshots/settings-verification.snapshot.spec.ts/chromium/verification-settings-on.png differdiff --git a/tests/e2e/__snapshots__/snapshots/sidebar.snapshot.spec.ts/chromium/sidebar-collapsed.png b/tests/e2e/__snapshots__/snapshots/sidebar.snapshot.spec.ts/chromium/sidebar-collapsed.pngnew file mode 100644index 0000000000..31c2cc7112Binary files /dev/null and b/tests/e2e/__snapshots__/snapshots/sidebar.snapshot.spec.ts/chromium/sidebar-collapsed.png differdiff --git a/tests/e2e/__snapshots__/snapshots/sidebar.snapshot.spec.ts/chromium/sidebar-conversation-panel.png b/tests/e2e/__snapshots__/snapshots/sidebar.snapshot.spec.ts/chromium/sidebar-conversation-panel.pngnew file mode 100644index 0000000000..9bfa56ab9eBinary files /dev/null and b/tests/e2e/__snapshots__/snapshots/sidebar.snapshot.spec.ts/chromium/sidebar-conversation-panel.png differdiff --git a/tests/e2e/__snapshots__/snapshots/sidebar.snapshot.spec.ts/chromium/sidebar-filter-menu.png b/tests/e2e/__snapshots__/snapshots/sidebar.snapshot.spec.ts/chromium/sidebar-filter-menu.pngnew file mode 100644index 0000000000..7db073fe83Binary files /dev/null and b/tests/e2e/__snapshots__/snapshots/sidebar.snapshot.spec.ts/chromium/sidebar-filter-menu.png differdiff --git a/tests/e2e/snapshots/settings-secrets.snapshot.spec.ts b/tests/e2e/snapshots/settings-secrets.snapshot.spec.tsnew file mode 100644index 0000000000..69245bd42d--- /dev/null+++ b/tests/e2e/snapshots/settings-secrets.snapshot.spec.ts@@ -0,0 +1,162 @@+import { test, expect, Page } from "@playwright/test";++/**+ * Visual snapshot tests for the Secrets Settings page (/settings/secrets).+ *+ * MSW pre-seeds two secrets in src/mocks/secrets-handlers.ts:+ * - OpenAI_API_Key+ * - Google_Maps_API_Key+ *+ * All five snapshots tell an iterative story:+ * 1. Default list (two pre-seeded rows)+ * 2. "Add New Secret" form open (empty)+ * 3. Form filled in with name + value+ * 4. After saving — list shows a third secret+ * 5. Delete confirmation modal open+ */++async function dismissConsentModal(page: Page) {+ await page+ .getByRole("button", { name: "Confirm preferences" })+ .click({ timeout: 3_000 })+ .catch(() => undefined);+}++async function setupMocks(page: Page) {+ await page.addInitScript(() => {+ window.localStorage.setItem("openhands-onboarded", "true");+ });+ // Keep conversations sidebar quiet (page.route wins for this cross-origin path+ // only; for same-origin MSW takes precedence and we rely on MSW data).+ await page.route("**/api/conversations/search**", async (route) => {+ await route.fulfill({+ status: 200,+ contentType: "application/json",+ body: JSON.stringify({ items: [], next_page_id: null }),+ });+ });+}++test.describe("Settings – Secrets Visual Snapshots", () => {+ test.setTimeout(60_000);+ // Run in serial so the MSW secrets Map stays consistent across steps+ test.describe.configure({ mode: "serial" });++ test("secrets list shows two pre-seeded rows", async ({ page }) => {+ await setupMocks(page);+ await page.goto("/settings/secrets");+ await dismissConsentModal(page);+ await page.waitForLoadState("networkidle");++ // Both secrets must be visible before taking the snapshot+ await expect(+ page.getByTestId("secret-item").first(),+ ).toBeVisible({ timeout: 10_000 });+ await expect(page.getByTestId("secret-item")).toHaveCount(2);++ const rootLayout = page.getByTestId("root-layout");+ await expect(rootLayout).toHaveScreenshot("secrets-list.png", {+ animations: "disabled",+ maxDiffPixelRatio: 0.01,+ });+ });++ test("add-new-secret form opens empty", async ({ page }) => {+ await setupMocks(page);+ await page.goto("/settings/secrets");+ await dismissConsentModal(page);++ await expect(+ page.getByTestId("secret-item").first(),+ ).toBeVisible({ timeout: 10_000 });++ // Click the "Add New Secret" button+ await page.getByTestId("add-secret-button").click();++ // The inline form should appear+ await expect(page.getByTestId("value-input")).toBeVisible({ timeout: 5_000 });++ const rootLayout = page.getByTestId("root-layout");+ await expect(rootLayout).toHaveScreenshot("secrets-add-form.png", {+ animations: "disabled",+ maxDiffPixelRatio: 0.01,+ });+ });++ test("add-new-secret form filled with name and value", async ({ page }) => {+ await setupMocks(page);+ await page.goto("/settings/secrets");+ await dismissConsentModal(page);++ await expect(+ page.getByTestId("secret-item").first(),+ ).toBeVisible({ timeout: 10_000 });+ await page.getByTestId("add-secret-button").click();+ await expect(page.getByTestId("value-input")).toBeVisible({ timeout: 5_000 });++ // Fill the secret name field+ await page.getByTestId("name-input").fill("ANTHROPIC_API_KEY");++ // Fill the secret value field+ await page.getByTestId("value-input").fill("sk-ant-snapshot-test-key");++ const rootLayout = page.getByTestId("root-layout");+ await expect(rootLayout).toHaveScreenshot("secrets-add-form-filled.png", {+ animations: "disabled",+ maxDiffPixelRatio: 0.01,+ });+ });++ test("after saving a secret the list shows three rows", async ({ page }) => {+ await setupMocks(page);+ await page.goto("/settings/secrets");+ await dismissConsentModal(page);++ await expect(+ page.getByTestId("secret-item").first(),+ ).toBeVisible({ timeout: 10_000 });+ await page.getByTestId("add-secret-button").click();+ await expect(page.getByTestId("value-input")).toBeVisible({ timeout: 5_000 });++ await page.getByTestId("name-input").fill("ANTHROPIC_API_KEY");+ await page.getByTestId("value-input").fill("sk-ant-snapshot-test-key");++ // Submit the form ("Add secret" is the i18n text for the submit button in add mode)+ await page.getByTestId("submit-button").click();++ // Wait for the form to close and the new secret to appear+ await expect(page.getByTestId("secret-item")).toHaveCount(3, {+ timeout: 10_000,+ });++ const rootLayout = page.getByTestId("root-layout");+ await expect(rootLayout).toHaveScreenshot("secrets-after-save.png", {+ animations: "disabled",+ maxDiffPixelRatio: 0.01,+ });+ });++ test("delete confirmation modal is shown for a secret", async ({ page }) => {+ await setupMocks(page);+ await page.goto("/settings/secrets");+ await dismissConsentModal(page);++ await expect(+ page.getByTestId("secret-item").first(),+ ).toBeVisible({ timeout: 10_000 });++ // Click the delete button on the first secret row+ await page.getByTestId("delete-secret-button").first().click();++ // The ConfirmationModal should appear+ await expect(+ page.getByTestId("confirmation-modal"),+ ).toBeVisible({ timeout: 5_000 });++ const rootLayout = page.getByTestId("root-layout");+ await expect(rootLayout).toHaveScreenshot("secrets-delete-confirm.png", {+ animations: "disabled",+ maxDiffPixelRatio: 0.01,+ });+ });+});diff --git a/tests/e2e/snapshots/settings-verification.snapshot.spec.ts b/tests/e2e/snapshots/settings-verification.snapshot.spec.tsnew file mode 100644index 0000000000..53848c6d17--- /dev/null+++ b/tests/e2e/snapshots/settings-verification.snapshot.spec.ts@@ -0,0 +1,121 @@+import { test, expect, Page } from "@playwright/test";++/**+ * Visual snapshot tests for:+ * - /settings/verification (Confirmation Mode toggle + Security Analyzer)+ * - /settings/condenser (Schema-driven condenser form)+ *+ * MSW provides the default settings (confirmation_mode: false) so the first+ * verification snapshot shows the toggle in the OFF position with a dimmed+ * Save Changes button. Toggling it ON reveals the Security Analyzer dropdown+ * and enables Save Changes — captured in the second snapshot.+ *+ * Three snapshots, not four: there is no separate "dirty" snapshot because+ * clicking the toggle IS the dirty action — the "ON" snapshot already captures+ * the dirty/enabled-Save-Changes state.+ */++async function dismissConsentModal(page: Page) {+ await page+ .getByRole("button", { name: "Confirm preferences" })+ .click({ timeout: 3_000 })+ .catch(() => undefined);+}++async function setupMocks(page: Page) {+ await page.addInitScript(() => {+ window.localStorage.setItem("openhands-onboarded", "true");+ });+}++test.describe("Settings – Verification & Condenser Visual Snapshots", () => {+ test.setTimeout(60_000);++ /**+ * Helper: wait for the verification page to be ready by checking for the+ * "Enable Confirmation Mode" label text (visible once settings are loaded).+ * The underlying checkbox is `hidden` in the DOM (a styled toggle pattern),+ * so we cannot use toBeVisible() on the checkbox itself.+ */+ async function waitForVerificationPage(page: Page) {+ await expect(+ page.getByText("Enable Confirmation Mode"),+ ).toBeVisible({ timeout: 10_000 });+ }++ test("verification settings with confirmation mode OFF (default)", async ({+ page,+ }) => {+ await setupMocks(page);+ await page.goto("/settings/verification");+ await dismissConsentModal(page);+ await page.waitForLoadState("networkidle");++ await waitForVerificationPage(page);++ // Security Analyzer combobox must NOT be present when toggle is off.+ // HeroUI Autocomplete does not forward data-testid; use role + label.+ await expect(+ page.getByRole("combobox", { name: /Security Analyzer/ }),+ ).toHaveCount(0);++ const rootLayout = page.getByTestId("root-layout");+ await expect(rootLayout).toHaveScreenshot(+ "verification-settings-off.png",+ { animations: "disabled", maxDiffPixelRatio: 0.01 },+ );+ });++ test("verification settings with confirmation mode ON shows security analyzer", async ({+ page,+ }) => {+ await setupMocks(page);+ await page.goto("/settings/verification");+ await dismissConsentModal(page);+ await waitForVerificationPage(page);++ // The underlying <input type="checkbox"> is `hidden`; clicking the visible+ // label that wraps it activates the form control through standard HTML+ // label–control association.+ await page+ .locator(`label:has([data-testid="confirmation-mode-toggle"])`)+ .click();++ // Security Analyzer dropdown should now appear.+ // The HeroUI Autocomplete component does not forward data-testid to the DOM;+ // match by accessible role + label instead.+ await expect(+ page.getByRole("combobox", { name: /Security Analyzer/ }),+ ).toBeVisible({ timeout: 5_000 });++ const rootLayout = page.getByTestId("root-layout");+ await expect(rootLayout).toHaveScreenshot(+ "verification-settings-on.png",+ { animations: "disabled", maxDiffPixelRatio: 0.01 },+ );+ });++ test("condenser settings page renders schema form", async ({ page }) => {+ await setupMocks(page);+ await page.goto("/settings/condenser");+ await dismissConsentModal(page);+ await page.waitForLoadState("networkidle");++ // Wait for the condenser form to render: the schema provides+ // "Enable default condenser" as the first field label+ await expect(+ page.getByText("Enable default condenser"),+ ).toBeVisible({ timeout: 15_000 });++ // The wrapper div with data-testid should be present once the form renders+ await expect(+ page.getByTestId("condenser-settings-screen"),+ ).toBeAttached({ timeout: 5_000 });++ const rootLayout = page.getByTestId("root-layout");+ await expect(rootLayout).toHaveScreenshot("condenser-settings.png", {+ animations: "disabled",+ maxDiffPixelRatio: 0.01,+ });+ });+});diff --git a/tests/e2e/snapshots/sidebar.snapshot.spec.ts b/tests/e2e/snapshots/sidebar.snapshot.spec.tsnew file mode 100644index 0000000000..de06d3d6bc--- /dev/null+++ b/tests/e2e/snapshots/sidebar.snapshot.spec.ts@@ -0,0 +1,116 @@+import { test, expect, Page } from "@playwright/test";++/**+ * Visual snapshot tests for the sidebar / conversation panel.+ *+ * MSW pre-seeds three conversations in src/mocks/conversation-handlers.ts:+ * 1. "My New Project" — execution_status: "waiting_for_confirmation"+ * 2. "Repo Testing" — execution_status: "idle"+ * 3. "Another Project" — execution_status: "idle"+ *+ * Three snapshots:+ * 1. conversation-panel — the panel itself with status dots + relative timestamps+ * 2. sidebar-collapsed — after clicking the collapse toggle (thin icon rail)+ * 3. new-conversation-popover — popover open showing workspace options+ */++async function dismissConsentModal(page: Page) {+ await page+ .getByRole("button", { name: "Confirm preferences" })+ .click({ timeout: 3_000 })+ .catch(() => undefined);+}++async function setupMocks(page: Page) {+ await page.addInitScript(() => {+ window.localStorage.setItem("openhands-onboarded", "true");+ });+ // Suppress proxy errors for file API (home page workspace scan)+ await page.route("**/api/file/**", async (route) => {+ await route.fulfill({+ status: 200,+ contentType: "application/json",+ body: JSON.stringify({ path: "/home", subdirs: [] }),+ });+ });+}++test.describe("Sidebar Visual Snapshots", () => {+ test.setTimeout(60_000);++ test("conversation panel shows three conversations with status dots", async ({+ page,+ }) => {+ await setupMocks(page);+ await page.goto("/conversations");+ await dismissConsentModal(page);+ await page.waitForLoadState("networkidle");++ // Wait for all three conversation cards to be present+ const conversationPanel = page.getByTestId("conversation-panel");+ await expect(conversationPanel).toBeVisible({ timeout: 15_000 });+ await expect(page.getByTestId("conversation-card")).toHaveCount(3, {+ timeout: 10_000,+ });++ // Scope the screenshot to just the sidebar panel (includes status dots)+ await expect(conversationPanel).toHaveScreenshot(+ "sidebar-conversation-panel.png",+ { animations: "disabled", maxDiffPixelRatio: 0.01 },+ );+ });++ test("sidebar collapses to an icon rail on toggle", async ({ page }) => {+ await setupMocks(page);+ await page.goto("/conversations");+ await dismissConsentModal(page);+ await page.waitForLoadState("networkidle");++ await expect(page.getByTestId("conversation-panel")).toBeVisible({+ timeout: 15_000,+ });++ // Click the collapse toggle (visible when sidebar is expanded)+ await page.getByTestId("sidebar-collapse-toggle").click();++ // Sidebar should now be in collapsed state+ const sidebarAside = page.locator("aside[data-collapsed='true']");+ await expect(sidebarAside).toBeVisible({ timeout: 5_000 });++ const rootLayout = page.getByTestId("root-layout");+ await expect(rootLayout).toHaveScreenshot("sidebar-collapsed.png", {+ animations: "disabled",+ maxDiffPixelRatio: 0.01,+ });+ });++ test("conversations filter menu opens from the filter toggle button", async ({+ page,+ }) => {+ await setupMocks(page);+ await page.goto("/conversations");+ await dismissConsentModal(page);+ await page.waitForLoadState("networkidle");++ await expect(page.getByTestId("conversation-panel")).toBeVisible({+ timeout: 15_000,+ });+ await expect(page.getByTestId("conversation-card")).toHaveCount(3, {+ timeout: 10_000,+ });++ // Click the filter toggle in the Conversations header+ await page.getByTestId("older-conversations-filter-toggle").click();++ // Filter menu should appear+ await expect(+ page.getByTestId("older-conversations-filter-menu"),+ ).toBeVisible({ timeout: 5_000 });++ const rootLayout = page.getByTestId("root-layout");+ await expect(rootLayout).toHaveScreenshot(+ "sidebar-filter-menu.png",+ { animations: "disabled", maxDiffPixelRatio: 0.01 },+ );+ });+});