diff --git a/client/src/App.test.tsx b/client/src/App.test.tsx index 9a39e8f..2ad820c 100644 --- a/client/src/App.test.tsx +++ b/client/src/App.test.tsx @@ -603,6 +603,22 @@ describe('App search', () => { ); }); + it('renders aria-hidden skeleton cards while loading and replaces them with results', async () => { + const { container } = renderApp([mockSearch('', [album])]); + const region = screen.getByRole('region', { name: 'Browse albums' }); + expect(region).toHaveAttribute('aria-busy', 'true'); + expect(resultStatus()).toHaveTextContent('Loading albums…'); + const skeletonGrid = container.querySelector('.album-grid--loading'); + expect(skeletonGrid).toBeInTheDocument(); + expect(skeletonGrid).toHaveAttribute('aria-hidden', 'true'); + expect(skeletonGrid?.querySelectorAll('.album-skeleton')).toHaveLength(8); + expect(screen.queryByRole('article')).not.toBeInTheDocument(); + + await screen.findByRole('article', { name: 'Abbey Road' }); + expect(container.querySelector('.album-grid--loading')).not.toBeInTheDocument(); + expect(region).toHaveAttribute('aria-busy', 'false'); + }); + it('replaces results for a new query rather than retaining the previous search', async () => { renderApp([mockSearch('Abbey'), mockSearch('missing', [])]); submitSearch('Abbey'); diff --git a/client/src/components/ResultsLayout.css b/client/src/components/ResultsLayout.css index 0dae989..29aea01 100644 --- a/client/src/components/ResultsLayout.css +++ b/client/src/components/ResultsLayout.css @@ -29,6 +29,82 @@ .album-grid > li { min-width: 0; } +.album-skeleton { + height: 100%; + display: flex; + flex-direction: column; +} +@container album-grid (width < 37.375rem) { + .album-skeleton { + max-width: 26rem; + margin-inline: auto; + } +} +.album-skeleton__cover, +.album-skeleton__line, +.album-skeleton__pill { + background: var(--surface-raised); + animation: album-skeleton-pulse 1.5s ease-in-out infinite; +} +.album-skeleton__cover { + aspect-ratio: 1; + border: 1px solid var(--border); + border-radius: 3px; +} +.album-skeleton__info { + flex: 1; + display: flex; + flex-direction: column; + gap: 0.5rem; + padding: 1.125rem 1rem 1rem; +} +.album-skeleton__line { + border-radius: 4px; +} +.album-skeleton__line--meta { + height: 0.85rem; + width: 45%; +} +.album-skeleton__line--title { + height: 1.4rem; + width: 82%; +} +.album-skeleton__line--artist { + height: 0.95rem; + width: 60%; +} +.album-skeleton__footer { + display: flex; + justify-content: space-between; + align-items: center; + gap: 0.75rem; + margin-top: auto; + padding-top: 1rem; +} +.album-skeleton__pill { + height: 1.75rem; + width: 4.5rem; + border-radius: 100px; +} +.album-skeleton__pill--short { + width: 5.5rem; +} +@keyframes album-skeleton-pulse { + 0%, + 100% { + opacity: 1; + } + 50% { + opacity: 0.55; + } +} +@media (prefers-reduced-motion: reduce) { + .album-skeleton__cover, + .album-skeleton__line, + .album-skeleton__pill { + animation: none; + } +} .empty-state { text-align: center; padding: 3rem 1rem; diff --git a/client/src/components/ResultsLayout.tsx b/client/src/components/ResultsLayout.tsx index 2d43ada..99cc982 100644 --- a/client/src/components/ResultsLayout.tsx +++ b/client/src/components/ResultsLayout.tsx @@ -27,6 +27,8 @@ interface Props { onReset: () => void; } +const SKELETON_CARD_COUNT = 8; + export default function ResultsLayout(props: Props) { const sentinel = useRef(null); const { @@ -129,7 +131,26 @@ export default function ResultsLayout(props: Props) { {props.hasQuery ? 'Retry search' : 'Retry albums'} - ) : props.loading ? null : props.totalCount === 0 ? ( + ) : props.loading ? ( + + ) : props.totalCount === 0 ? (

No albums found

diff --git a/docs/AI-USAGE.md b/docs/AI-USAGE.md index 70d3980..ce921d0 100644 --- a/docs/AI-USAGE.md +++ b/docs/AI-USAGE.md @@ -105,6 +105,7 @@ the part that matters most. | 2026-11-17 | erikhfj | Antigravity | #91, E2E search helper fix: updated `e2e/tests/search.spec.ts` to match the `Search` and `Filters` buttons with `exact: true` so `Clear recent searches` does not trigger a strict-mode violation, and cleared `E2E_USER_ID`'s recorded search history during cleanup. Verified locally with two consecutive full `pnpm test:e2e` runs against a throwaway seeded PostgreSQL stack. | | 2026-11-20 | erikhfj | Antigravity | #100, review author privacy: removed `User.id` from `schema.graphql` and the `AlbumDetail` query, replaced `Listener ` with deterministic SHA-256 music pseudonyms in `server/src/userIdentity.ts` (including read-time sanitization of legacy labels in `Review.user`), added `User` cache merge policy, and updated schema/unit/client tests and `docs/architecture.md`. Verified with `pnpm codegen`, `pnpm format:check`, `pnpm lint`, `pnpm typecheck`, `pnpm test`, and `pnpm build`. | | 2026-11-20 | erikhfj | Antigravity | #103, search history error visibility and focus: moved the search history error message and Retry button inside the open `RecentSearches` dropdown so closed-state errors cannot overlap page content, returned retry success from `useSearchHistory`, restored focus to the search input after a successful retry in `SearchForm`, and added unit/integration tests. Verified with `pnpm format:check && pnpm lint && pnpm typecheck && pnpm test && pnpm build`. | +| 2026-11-20 | erikhfj | Antigravity | #95, loading skeleton cards: rendered 8 `aria-hidden="true"` placeholder cards inside `.album-grid--loading` while `ResultsLayout` is loading so the layout does not collapse, styled with plain CSS and `prefers-reduced-motion` support, kept `role="status"` and `aria-busy` unchanged, and added a loading-state test in `App.test.tsx`. Verified with `pnpm format:check && pnpm lint && pnpm typecheck && pnpm test && pnpm build`. | | 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. | ## Notes