@@ -139,6 +191,7 @@ export default function FilterPanel(props: Props) {
ref={toggleRef}
type="button"
className="filter-toggle"
+ aria-haspopup="dialog"
aria-expanded={open}
aria-controls="filter-options"
onClick={() => setOpen(!open)}
@@ -166,11 +219,31 @@ export default function FilterPanel(props: Props) {
))}
)}
-
+
+
);
}
diff --git a/client/src/test/setup.ts b/client/src/test/setup.ts
index 4f41d02..e2a0e9b 100644
--- a/client/src/test/setup.ts
+++ b/client/src/test/setup.ts
@@ -13,3 +13,12 @@ afterEach(() => {
cleanup();
window.history.replaceState({}, '', '/');
});
+
+// jsdom does not implement dialog's modal lifecycle. Native focus containment,
+// Escape and background inertness are verified in the browser tests.
+HTMLDialogElement.prototype.showModal = function () {
+ this.setAttribute('open', '');
+};
+HTMLDialogElement.prototype.close = function () {
+ this.removeAttribute('open');
+};
diff --git a/docs/AI-USAGE.md b/docs/AI-USAGE.md
index 5a9659f..397cc61 100644
--- a/docs/AI-USAGE.md
+++ b/docs/AI-USAGE.md
@@ -109,6 +109,7 @@ the part that matters most.
| 2026-11-22 | evenkkl | Claude | #96, skip count and facet queries on Load more: Claude made the search aggregates lazy `AlbumConnection` field resolvers, added a `SearchAlbumsPage` query for Load more, kept page one's count and facets in the Apollo merge, and added server and client tests. Verified with lint, typecheck, the test suites and the PostgreSQL tests on PGlite. |
| 2026-11-22 | erikhfj | Antigravity | #117, stabilized `ReviewForm.test.tsx`: traced the intermittent CI failure (run `88055`) to `findByRole('status')` resolving via `MutationObserver` before React's passive `useEffect` focused `statusRef`, and wrapped the status focus assertions in `waitFor`. Verified with 10 consecutive test runs plus `pnpm format:check && pnpm lint && pnpm typecheck && pnpm test`. |
| 2026-11-22 | erikhfj | Antigravity | #107, documented the team's AI task delegation, verification, and review workflow in `docs/AI-USAGE.md`, reflecting actual practices across all four contributors and complementing #97's prompt-context section. Verified with `pnpm format:check && pnpm lint && pnpm typecheck && pnpm test`. |
+| 2026-11-23 | robertky | Codex (ChatGPT) | #104 review follow-up: combined the side drawer with the merged country preview, added backdrop dismissal and a keyboard focus loop, corrected the results-status test matcher and component documentation, and expanded the Playwright filter journey. Verified with `pnpm format:check`, `pnpm lint`, `pnpm typecheck`, `pnpm test`, `pnpm build`, and `pnpm test:e2e` against an isolated seeded PostgreSQL database. |
## Task delegation and verification workflow
diff --git a/e2e/tests/filters.spec.ts b/e2e/tests/filters.spec.ts
new file mode 100644
index 0000000..cd6c68e
--- /dev/null
+++ b/e2e/tests/filters.spec.ts
@@ -0,0 +1,74 @@
+import { expect, test } from '@playwright/test';
+
+for (const viewport of [
+ { name: 'desktop', width: 1440, height: 900 },
+ { name: 'mobile', width: 390, height: 844 },
+]) {
+ test(`filter drawer supports keyboard use and URL state on ${viewport.name}`, async ({
+ page,
+ }, testInfo) => {
+ await page.setViewportSize(viewport);
+ await page.goto('./?q=beatles&sort=TITLE_DESC');
+ await expect(page.getByRole('status').filter({ hasText: 'Showing' })).toHaveText(
+ /Showing 2 of 2 /,
+ );
+
+ await page.getByRole('button', { name: 'Filters', exact: true }).focus();
+ await page.keyboard.press('Enter');
+ const drawer = page.getByRole('dialog', { name: 'Refine albums' });
+ const close = drawer.getByRole('button', { name: 'Close filters' });
+ await expect(drawer).toBeVisible();
+ await expect(close).toBeFocused();
+
+ // Native modal behavior keeps keyboard focus and accessibility navigation
+ // inside the drawer, including when tabbing backwards from its first control.
+ await page.keyboard.press('Shift+Tab');
+ await expect
+ .poll(() => drawer.evaluate((element) => element.contains(document.activeElement)))
+ .toBe(true);
+ await page.keyboard.press('Tab');
+ await expect(close).toBeFocused();
+
+ await drawer.getByRole('checkbox', { name: /1960s/ }).check();
+ await expect(page).toHaveURL(/[?&]decades=1960/);
+ await expect(drawer.getByRole('status')).toHaveText('1 active filter');
+ const bounds = await drawer.boundingBox();
+ expect(bounds).not.toBeNull();
+ expect(bounds!.x).toBeGreaterThanOrEqual(0);
+ expect(bounds!.x + bounds!.width).toBeLessThanOrEqual(viewport.width + 1);
+ expect(bounds!.width).toBeLessThanOrEqual(448);
+ expect(await drawer.evaluate((el) => el.scrollWidth <= el.clientWidth)).toBe(true);
+ await page.screenshot({ path: testInfo.outputPath('filter-panel.png') });
+
+ if (viewport.width > 448) {
+ await page.mouse.click(0, 0);
+ await expect(drawer).not.toBeVisible();
+ const filterButton = page.getByRole('button', { name: 'Filters (1)' });
+ await expect(filterButton).toBeFocused();
+ await filterButton.click();
+ await expect(drawer).toBeVisible();
+ }
+
+ await page.keyboard.press('Escape');
+ await expect(drawer).not.toBeVisible();
+ await expect(page.getByRole('button', { name: 'Filters (1)' })).toBeFocused();
+ await expect(page.getByRole('list', { name: 'Active filters' })).toContainText(
+ '1960s',
+ );
+ await expect(page.getByRole('combobox', { name: 'Sort by' })).toHaveValue(
+ 'TITLE_DESC',
+ );
+
+ await page.reload();
+ await page.getByRole('button', { name: 'Filters (1)' }).click();
+ await expect(drawer.getByRole('checkbox', { name: /1960s/ })).toBeChecked();
+ await drawer.getByRole('button', { name: 'Clear filters' }).click();
+ await expect(drawer.getByRole('status')).toHaveText('0 active filters');
+ await close.click();
+ await expect(
+ page.getByRole('button', { name: 'Filters', exact: true }),
+ ).toBeFocused();
+ await expect(page).toHaveURL(/\?q=beatles&sort=TITLE_DESC$/);
+ await expect(page.getByRole('list', { name: 'Active filters' })).toHaveCount(0);
+ });
+}
diff --git a/e2e/tests/search.spec.ts b/e2e/tests/search.spec.ts
index 5d74157..d14152e 100644
--- a/e2e/tests/search.spec.ts
+++ b/e2e/tests/search.spec.ts
@@ -46,10 +46,10 @@ test('search, filter, sort, open an album and keep a review across a reload', as
await page.getByRole('button', { name: 'Filters', exact: true }).click();
await page.getByRole('checkbox', { name: /1960s/ }).check();
await expect(page).toHaveURL(/[?&]decades=1960/);
+ await page.keyboard.press('Escape');
await expect(
page.getByRole('button', { name: 'Filters (1)', exact: true }),
).toBeVisible();
- await page.keyboard.press('Escape');
// Sort: both directions, so the test cannot pass by accident on insertion order.
const sort = page.getByRole('combobox', { name: 'Sort by' });