From cf97f0454eda5c3ec72f9053d585d51b54297d30 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 27 Jun 2026 09:30:56 +0000 Subject: [PATCH 1/8] Initial plan From 09a2299c6749fc3223a3ec70b525b7d60e676155 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 27 Jun 2026 09:33:21 +0000 Subject: [PATCH 2/8] Add fail-fast smoke mode switch guard --- tests/ui-smoke.spec.ts | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/tests/ui-smoke.spec.ts b/tests/ui-smoke.spec.ts index f0b94b865..5eceb1e9e 100644 --- a/tests/ui-smoke.spec.ts +++ b/tests/ui-smoke.spec.ts @@ -47,13 +47,34 @@ async function fillVisibleQuestionInput(page: Page, value: string) { } async function switchToDocumentSearchMode(page: Page) { - const documentsMode = page.getByRole("button", { name: "Switch to document search mode" }); - await expect(documentsMode).toBeVisible(); - await expect(documentsMode).toBeEnabled(); + const legacyDocumentsMode = page.getByRole("button", { name: "Switch to document search mode" }); + if (await legacyDocumentsMode.isVisible().catch(() => false)) { + await expect(legacyDocumentsMode).toBeEnabled(); + await expect(async () => { + await legacyDocumentsMode.click(); + await expect(legacyDocumentsMode).toHaveAttribute("aria-pressed", "true", { timeout: 1_000 }); + }).toPass({ timeout: 8_000 }); + return; + } + + const appModeMenu = page.getByRole("button", { name: /Current app mode:/ }); + if (!(await appModeMenu.isVisible().catch(() => false))) { + throw new Error( + "Could not switch to document search mode: neither the legacy mode toggle nor the app mode menu is visible.", + ); + } + await expect(appModeMenu).toBeEnabled(); await expect(async () => { - await documentsMode.click(); - await expect(documentsMode).toHaveAttribute("aria-pressed", "true", { timeout: 1_000 }); + await appModeMenu.click({ force: true }); + await expect(appModeMenu).toHaveAttribute("aria-expanded", "true", { timeout: 2_000 }); + const documentsMode = page + .locator('[role="menuitemradio"]') + .filter({ hasText: /^Documents/ }) + .first(); + await expect(documentsMode).toBeVisible({ timeout: 3_000 }); + await documentsMode.click({ force: true }); + await expect(page.getByRole("button", { name: "Current app mode: Documents" })).toBeVisible({ timeout: 2_000 }); }).toPass({ timeout: 8_000 }); } From 74edfdf744f804f057b1d93fa0c333e16f2a7d0f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 27 Jun 2026 09:35:44 +0000 Subject: [PATCH 3/8] Tighten smoke mode switch fallback --- tests/ui-smoke.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ui-smoke.spec.ts b/tests/ui-smoke.spec.ts index 5eceb1e9e..388f5fe80 100644 --- a/tests/ui-smoke.spec.ts +++ b/tests/ui-smoke.spec.ts @@ -66,14 +66,14 @@ async function switchToDocumentSearchMode(page: Page) { await expect(appModeMenu).toBeEnabled(); await expect(async () => { - await appModeMenu.click({ force: true }); + await appModeMenu.click(); await expect(appModeMenu).toHaveAttribute("aria-expanded", "true", { timeout: 2_000 }); const documentsMode = page .locator('[role="menuitemradio"]') .filter({ hasText: /^Documents/ }) .first(); await expect(documentsMode).toBeVisible({ timeout: 3_000 }); - await documentsMode.click({ force: true }); + await documentsMode.click(); await expect(page.getByRole("button", { name: "Current app mode: Documents" })).toBeVisible({ timeout: 2_000 }); }).toPass({ timeout: 8_000 }); } From c6e7c70e097cb884963b50853ee6f493128953c0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 27 Jun 2026 09:36:34 +0000 Subject: [PATCH 4/8] Refine smoke menu selector --- tests/ui-smoke.spec.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/ui-smoke.spec.ts b/tests/ui-smoke.spec.ts index 388f5fe80..e5c6aeb40 100644 --- a/tests/ui-smoke.spec.ts +++ b/tests/ui-smoke.spec.ts @@ -68,10 +68,7 @@ async function switchToDocumentSearchMode(page: Page) { await expect(async () => { await appModeMenu.click(); await expect(appModeMenu).toHaveAttribute("aria-expanded", "true", { timeout: 2_000 }); - const documentsMode = page - .locator('[role="menuitemradio"]') - .filter({ hasText: /^Documents/ }) - .first(); + const documentsMode = page.getByRole("menuitemradio", { name: /^Documents\b/ }); await expect(documentsMode).toBeVisible({ timeout: 3_000 }); await documentsMode.click(); await expect(page.getByRole("button", { name: "Current app mode: Documents" })).toBeVisible({ timeout: 2_000 }); From d44658fd0ea60b65be1b6b14b9387dddedec98ec Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 27 Jun 2026 09:37:13 +0000 Subject: [PATCH 5/8] Deduplicate smoke visibility checks --- tests/ui-smoke.spec.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/ui-smoke.spec.ts b/tests/ui-smoke.spec.ts index e5c6aeb40..9ba611dc0 100644 --- a/tests/ui-smoke.spec.ts +++ b/tests/ui-smoke.spec.ts @@ -29,6 +29,10 @@ function visibleQuestionInput(page: Page) { return page.locator('[aria-label="Search indexed guidelines by question or keyword"]:visible').first(); } +async function isVisibleSafely(locator: Locator) { + return locator.isVisible().catch(() => false); +} + async function fillVisibleQuestionInput(page: Page, value: string) { const questionInput = visibleQuestionInput(page); const submitAnswer = page.getByRole("button", { name: "Generate source-backed answer" }); @@ -48,7 +52,7 @@ async function fillVisibleQuestionInput(page: Page, value: string) { async function switchToDocumentSearchMode(page: Page) { const legacyDocumentsMode = page.getByRole("button", { name: "Switch to document search mode" }); - if (await legacyDocumentsMode.isVisible().catch(() => false)) { + if (await isVisibleSafely(legacyDocumentsMode)) { await expect(legacyDocumentsMode).toBeEnabled(); await expect(async () => { await legacyDocumentsMode.click(); @@ -58,7 +62,7 @@ async function switchToDocumentSearchMode(page: Page) { } const appModeMenu = page.getByRole("button", { name: /Current app mode:/ }); - if (!(await appModeMenu.isVisible().catch(() => false))) { + if (!(await isVisibleSafely(appModeMenu))) { throw new Error( "Could not switch to document search mode: neither the legacy mode toggle nor the app mode menu is visible.", ); From d8c6d4ddb628e8f196cfe0c0cc03abd63487694b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 27 Jun 2026 09:37:49 +0000 Subject: [PATCH 6/8] Anchor smoke mode menu selector --- tests/ui-smoke.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui-smoke.spec.ts b/tests/ui-smoke.spec.ts index 9ba611dc0..57a590d75 100644 --- a/tests/ui-smoke.spec.ts +++ b/tests/ui-smoke.spec.ts @@ -61,7 +61,7 @@ async function switchToDocumentSearchMode(page: Page) { return; } - const appModeMenu = page.getByRole("button", { name: /Current app mode:/ }); + const appModeMenu = page.getByRole("button", { name: /^Current app mode:/ }); if (!(await isVisibleSafely(appModeMenu))) { throw new Error( "Could not switch to document search mode: neither the legacy mode toggle nor the app mode menu is visible.", From 1c0c4a444a8d58643e395c8ed63e9f6a8ca9f2e6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 27 Jun 2026 09:38:32 +0000 Subject: [PATCH 7/8] Reuse smoke mode menu locator --- tests/ui-smoke.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui-smoke.spec.ts b/tests/ui-smoke.spec.ts index 57a590d75..f58a897da 100644 --- a/tests/ui-smoke.spec.ts +++ b/tests/ui-smoke.spec.ts @@ -75,7 +75,7 @@ async function switchToDocumentSearchMode(page: Page) { const documentsMode = page.getByRole("menuitemradio", { name: /^Documents\b/ }); await expect(documentsMode).toBeVisible({ timeout: 3_000 }); await documentsMode.click(); - await expect(page.getByRole("button", { name: "Current app mode: Documents" })).toBeVisible({ timeout: 2_000 }); + await expect(appModeMenu).toHaveAccessibleName("Current app mode: Documents", { timeout: 2_000 }); }).toPass({ timeout: 8_000 }); } From 5d0d872cc3e3bc8cbff1f4fb04eebfcab23b8dca Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 27 Jun 2026 09:39:11 +0000 Subject: [PATCH 8/8] Clarify smoke visibility helper name --- tests/ui-smoke.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ui-smoke.spec.ts b/tests/ui-smoke.spec.ts index f58a897da..a44ba8ef3 100644 --- a/tests/ui-smoke.spec.ts +++ b/tests/ui-smoke.spec.ts @@ -29,7 +29,7 @@ function visibleQuestionInput(page: Page) { return page.locator('[aria-label="Search indexed guidelines by question or keyword"]:visible').first(); } -async function isVisibleSafely(locator: Locator) { +async function isVisibleWithoutThrow(locator: Locator) { return locator.isVisible().catch(() => false); } @@ -52,7 +52,7 @@ async function fillVisibleQuestionInput(page: Page, value: string) { async function switchToDocumentSearchMode(page: Page) { const legacyDocumentsMode = page.getByRole("button", { name: "Switch to document search mode" }); - if (await isVisibleSafely(legacyDocumentsMode)) { + if (await isVisibleWithoutThrow(legacyDocumentsMode)) { await expect(legacyDocumentsMode).toBeEnabled(); await expect(async () => { await legacyDocumentsMode.click(); @@ -62,7 +62,7 @@ async function switchToDocumentSearchMode(page: Page) { } const appModeMenu = page.getByRole("button", { name: /^Current app mode:/ }); - if (!(await isVisibleSafely(appModeMenu))) { + if (!(await isVisibleWithoutThrow(appModeMenu))) { throw new Error( "Could not switch to document search mode: neither the legacy mode toggle nor the app mode menu is visible.", );