Fix frontend e2e sidebar and WCAG regression failures#672
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses frontend Playwright E2E regressions and WCAG AA audit failures by stabilizing accessibility labeling (code blocks/tables), hardening sidebar-related tests, and moving analytics scripts to static public assets with new contract tests.
Changes:
- Added/updated Playwright E2E suites (UI regressions, pivots, WCAG AA) plus Playwright config and CI workflow integration.
- Improved a11y behavior by generating stable accessible labels for code regions and making horizontally scrollable tables keyboard-focusable.
- Migrated analytics script delivery from Astro routes to static
public/scripts/analytics/*and added unit/E2E contract tests.
Reviewed changes
Copilot reviewed 28 out of 30 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/frontend/tests/unit/analytics-script-contracts.test.js | Adds unit contract tests to ensure analytics scripts are referenced and present as static assets. |
| src/frontend/tests/e2e/wcag-aa.spec.js | Introduces Axe-based WCAG A/AA audits across key pages (marks large API page as slow). |
| src/frontend/tests/e2e/ui-regressions.spec.js | Adds regression coverage for install modal, cookie consent, footer prefs, synced tabs, and sidebar persistence. |
| src/frontend/tests/e2e/pivot-selector.spec.js | Adds E2E coverage for pivot selector query-string state/restore. |
| src/frontend/tests/e2e/helpers.js | Centralizes cookie dismissal and cookie-consent polling helpers for E2E tests. |
| src/frontend/tests/e2e/analytics-scripts.spec.js | Adds E2E smoke checks for analytics script endpoints and home-page references. |
| src/frontend/src/pages/track.js | Removes dynamic analytics route in favor of static public asset delivery. |
| src/frontend/src/pages/1ds.js | Removes dynamic analytics route in favor of static public asset delivery. |
| src/frontend/src/content/docs/get-started/install-cli.mdx | Updates repeated code samples with distinct titles to avoid a11y label collisions. |
| src/frontend/src/content/docs/get-started/aspire-vscode-extension.mdx | Updates repeated code sample titles to avoid duplicate accessible names. |
| src/frontend/src/components/MicrosoftFooter.astro | Adjusts footer column semantics/labeling to avoid landmark/name duplication. |
| src/frontend/src/components/FreeAndOpenSourceAside.astro | Tweaks heading semantics (h5→p) to align with accessibility changes. |
| src/frontend/src/components/FooterResources.astro | Adjusts footer column semantics/labeling to avoid landmark/name duplication. |
| src/frontend/src/components/FooterPreferences.astro | Adjusts footer semantics/markup consistency while preserving preferences behavior. |
| src/frontend/src/components/FooterLinks.astro | Refactors footer community links rendering and formatting. |
| src/frontend/src/components/FooterLegal.astro | Adjusts footer column semantics/labeling to avoid landmark/name duplication. |
| src/frontend/src/components/AppHostBuilder.astro | Formatting + minor style token adjustment affecting active toggle color. |
| src/frontend/src/components/api-reference/MemberCardBase.astro | Refactors markup (including section labels) and formatting for API member cards. |
| src/frontend/src/components/api-reference/MemberCard.astro | Refactors markup (including section labels) and formatting for API member cards. |
| src/frontend/src/components/AccessibleCodeButtons.astro | Adds code-region labeling + scrollable table focusability enhancements and reruns on navigation/resize. |
| src/frontend/public/scripts/analytics/track.js | Adds static analytics tracking bootstrap script under public assets. |
| src/frontend/public/scripts/analytics/1ds.js | Adds static 1DS bootstrap script under public assets. |
| src/frontend/pnpm-lock.yaml | Adds lock entries for Playwright Test + Axe Playwright dependencies. |
| src/frontend/playwright.config.mjs | Adds Playwright test runner configuration with multi-viewport projects and webServer. |
| src/frontend/package.json | Adds test scripts and Playwright/Axe devDependencies for E2E + a11y testing. |
| src/frontend/config/head.attrs.ts | Updates head script references to point to static analytics assets. |
| src/frontend/config/cookie.config.ts | Adjusts cookie-consent behavior for E2E via env flag. |
| package.json | Adds root-level test script that delegates to the frontend. |
| .gitignore | Ignores Playwright reports and test-results artifacts. |
| .github/workflows/frontend-build.yml | Adds unit + Playwright smoke tests, uploads reports, and summarizes quality gates in CI. |
Files not reviewed (1)
- src/frontend/pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Refactor MemberCardBase.astro for improved readability and structure. - Introduce Playwright configuration for end-to-end testing. - Add tests for analytics scripts to ensure correct loading and content. - Implement helper functions for cookie consent management in tests. - Create tests for pivot selector functionality and UI regressions. - Conduct WCAG AA compliance audits on key pages. - Establish unit tests for analytics script contracts to verify file existence and content.
…om components - Implemented helper functions for cookie consent management in e2e tests. - Created e2e tests for pivot selection and cookie consent behavior. - Added UI regression tests to verify analytics consent and theme persistence. - Conducted WCAG AA audits on key pages to ensure accessibility compliance. - Developed unit tests for analytics script contracts and custom Astro components. - Configured Vitest for unit testing with specific settings for Astro components.
- Implemented `update-samples.ts` to fetch and process sample data from GitHub, including downloading images and rewriting documentation links. - Created `update-ts-api.ts` to regenerate TypeScript API reference data using the AtsJsonGenerator tool, with checks for prerequisites like dotnet SDK and Aspire CLI. - Added end-to-end tests for RSS feed endpoint and link behavior in `rss.spec.ts`. - Introduced type-checking tests for component props in `component-props.contracts.ts`, ensuring proper prop validation across various components.
- Moved marker and collapse value shifting logic to a new shared file: SimpleAppHostCode.shared.ts. - Simplified SimpleAppHostCode.astro by utilizing the new shared functions. - Added a function to retrieve code snippets based on the selected language. - Introduced floating-icon-layout.ts for managing floating icon positions and animations in TopicHero component. - Updated TopicHero.astro to use the new floating icon layout logic. - Adjusted import paths across various components and tests for consistency. - Enhanced type definitions and improved code organization for better maintainability.
db1521f to
0338269
Compare
…collapse state persistence
…it test for rendering - fixes #676
JamesNK
left a comment
There was a problem hiding this comment.
Nice work stabilizing the test suites and converting the scripts to TypeScript. Left a few comments — the 404 detection regression in FooterLinks and the OsAwareTabs instanceof check are the ones worth addressing; the rest are nits.
| const gitHubLink = links.filter(l => l.label == 'GitHub')[0].href || null; | ||
| const discordLink = links.filter(l => l.label == 'Discord')[0].href || null; | ||
| const is404 = Astro.locals.starlightRoute?.entry?.slug === "404"; | ||
| const gitHubLink = links.find((link) => link.label === 'GitHub')?.href ?? null; |
There was a problem hiding this comment.
This breaks 404 detection for localized pages. The old check Astro.locals.starlightRoute?.entry?.slug === "404" matched all locales (e.g. /ja/404/, /zh-CN/404/), but this pathname check only matches the English variants. Community links will incorrectly render on localized 404 pages.
Consider restoring the slug-based check, or using a regex/includes match on the pathname.
| tab.setAttribute('aria-selected', isSelected ? 'true' : 'false'); | ||
| tab.setAttribute('tabindex', isSelected ? '0' : '-1'); | ||
| }); | ||
|
|
There was a problem hiding this comment.
The findIndex check uses instanceof HTMLAnchorElement, but if Starlight renders tabs as <button> elements this will silently return -1 and activateTabByLabel will exit without switching any tab. The script then sets the localStorage preference at the bottom but the UI won't visually reflect it on first load.
Consider relaxing the check to tab instanceof HTMLElement (or just check tab.textContent) to handle both <a> and <button> tab implementations.
| }, | ||
| { | ||
| files: ['tests/**/*.ts'], | ||
| ...tseslint.configs.disableTypeChecked, |
There was a problem hiding this comment.
This disables type-checked lint rules for all test files including tests/typecheck/component-props.contracts.ts, whose entire purpose is compile-time type validation via @ts-expect-error annotations. Consider narrowing the glob to just tests/e2e/**/*.ts if only the Playwright files are causing issues.
| <aside class="api-experimental-aside"> | ||
| <svg | ||
| width="16" | ||
| height="16" |
There was a problem hiding this comment.
Nit: the section labels (Parameters, Returns, Exceptions, Remarks, Examples) were demoted from <h5> to <p>. These are no longer in the heading hierarchy, which makes it harder for screen-reader users to navigate within a member card by headings. Since this file is one of the most heading-dense surfaces on the API reference, the <h5> elements were useful navigation landmarks.
Was this intentional (e.g. to fix an axe violation about heading order), or incidental?
There was a problem hiding this comment.
Intentional, they should not have been headings before.
|
|
||
| const parsedUrl = url instanceof URL ? url : new URL(url); | ||
| return fetch(url, { ...options, agent: selectAgent(parsedUrl) }); | ||
| } No newline at end of file |
There was a problem hiding this comment.
Nit: missing trailing newline at end of file.
Summary
Fixes #676
Also, adds tests!
This PR fixes the frontend end-to-end failures that were showing up in the sidebar regression test and the WCAG AA audit suite, and it also folds in the broader frontend hardening work that landed alongside those fixes.
What changed
Why
This work addressed a few related frontend maintenance issues at the same time:
Validation
Ran targeted validation against the Astro dev server and frontend test suites:
Notes:
API sidebar collapse state persists across reloads