Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions tests/ui-smoke.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ function visibleQuestionInput(page: Page) {
return page.locator('[aria-label="Search indexed guidelines by question or keyword"]:visible').first();
}

async function isVisibleWithoutThrow(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" });
Expand All @@ -47,13 +51,31 @@ 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 isVisibleWithoutThrow(legacyDocumentsMode)) {
await expect(legacyDocumentsMode).toBeEnabled();
await expect(async () => {
await legacyDocumentsMode.click();
await expect(legacyDocumentsMode).toHaveAttribute("aria-pressed", "true", { timeout: 1_000 });
}).toPass({ timeout: 8_000 });
Comment on lines +56 to +60
return;
}

const appModeMenu = page.getByRole("button", { name: /^Current app mode:/ });
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.",
);
}
await expect(appModeMenu).toBeEnabled();

await expect(async () => {
await appModeMenu.click();
await expect(appModeMenu).toHaveAttribute("aria-expanded", "true", { timeout: 2_000 });
const documentsMode = page.getByRole("menuitemradio", { name: /^Documents\b/ });
await expect(documentsMode).toBeVisible({ timeout: 3_000 });
await documentsMode.click();
await expect(documentsMode).toHaveAttribute("aria-pressed", "true", { timeout: 1_000 });
await expect(appModeMenu).toHaveAccessibleName("Current app mode: Documents", { timeout: 2_000 });
}).toPass({ timeout: 8_000 });
Comment on lines 72 to 79
}

Expand Down