Skip to content

Playwright end-to-end test suite#500

Open
otavionvidia wants to merge 3 commits into
NVIDIA-AI-Blueprints:developfrom
otavionvidia:develop
Open

Playwright end-to-end test suite#500
otavionvidia wants to merge 3 commits into
NVIDIA-AI-Blueprints:developfrom
otavionvidia:develop

Conversation

@otavionvidia
Copy link
Copy Markdown
Contributor

@otavionvidia otavionvidia commented Apr 28, 2026

Description

Adds a comprehensive Playwright end-to-end test suite for the React frontend, plus a CI workflow to run it on every PR. The suite ships 59 tests across 9 spec areas (chat, collections, settings, navigation, notifications, accessibility, visual, integration, error states) with deterministic mocks, Page Object Models, axe-core a11y assertions, and V8 + CSS code coverage via monocart-reporter.

What's included

Test infrastructure (frontend/e2e/)

  • playwright.config.ts with 6 projects: chromium / webkit (default mocked), flaky-chromium (selective retries for @flaky-tagged tests), firefox (opt-in), visual (screenshots), integration (real backend, opt-in via E2E_INTEGRATION=1).
  • Typed fixtures (base.ts, mock-api.ts, coverage.ts, seed-storage.ts, axe.ts) — all responses default to deterministic page.route mocks; integration mode swaps in a no-op stub.
  • Page Object Models for every major UI surface (ChatPage, CollectionsPanel, CitationsDrawer, NotificationPanel, SettingsPage, etc.) backed by data-testid selectors.
  • Hybrid streaming control: mockApi.streamChat({ hold: true }) + releaseChat() removes timing-based flake. Global addInitScript disables CSS animations/transitions in all tests.
  • 1×1 transparent PNG fixture for upload tests, real SSE response builder (utils/sse.ts), localStorage seeding helpers.

Frontend changes (frontend/src/)

  • Added data-testid and aria-label attributes to ~16 components across chat, collections, notifications, settings, and layout (no behavioral changes).
  • One subtle fix: data-testid="collection-drawer" is on an inner <Stack> inside CollectionDrawer rather than the <SidePanel> wrapper, to avoid clobbering KUI's internal nv-side-panel-content testid that unit tests rely on.

CI (.github/workflows/e2e.yml)

  • Sharded mocked runs on chromium/webkit, dedicated a11y + visual jobs, opt-in integration job. Reports merged via playwright merge-reports and uploaded as artifacts.
  • Coverage thresholds (lines 50%, statements 50%, functions 40%, branches 25%) enforced when COVERAGE_ENFORCE=1.

Tooling

  • 14 new pnpm scripts (e2e, e2e:chromium, e2e:integration, e2e:a11y, e2e:visual, e2e:flaky, e2e:report, …).
  • frontend/.gitignore + frontend/e2e/.gitignore exclude playwright-report/, test-results/, blob-report/.
  • frontend/e2e/README.md documents run modes, structure, coverage interpretation, CI behavior, and known caveats.

Verification

  • pnpm e2e:chromium59/59 passing, ~13s wall time on a clean checkout.
  • Suite is deterministic: 10 consecutive runs locally with no flakes.
  • One pre-existing app bug surfaced by the streaming/stop-button test and documented inline in frontend/e2e/tests/chat/streaming.spec.ts (separate useSendMessage() instances each create their own AbortController, so the stop button aborts a different controller than the in-flight fetch — left as a follow-up; the test asserts current behavior).

Not included

  • No backend (src/nvidia_rag/), Helm, or docker-compose.yaml changes.
  • No production code changes beyond the testid/aria-label additions noted above.

Checklist

  • I am familiar with the Contributing Guidelines.
  • All commits are signed-off (git commit -s) and GPG signed (git commit -S).
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.
  • If adjusting docker-compose.yaml environment variables have you ensured those are mimicked in the Helm values.yaml file.

Introduces an end-to-end test suite under frontend/e2e/ covering chat,
collections, settings, navigation, notifications, accessibility, visual
regression, and an opt-in real-backend smoke suite. Built around a
mocked-API fixture (page.route) so the default run is fast (~13s on
chromium) and deterministic.

Key design choices, aligned with 2026 Playwright best practices:
- Hybrid backend strategy: mocks by default, separate "integration"
  project for real-backend validation.
- Page Object Model with user-intent methods over semantic locators.
- Composed waitForAppReady (DOMContentLoaded + networkidle + header
  visible) to settle React Query's cascade of /api/health +
  /api/configuration + /api/collections requests.
- Global animations-off init script via page.addInitScript so KUI
  Popover/SidePanel/Dropdown enter-leave animations don't race
  assertions.
- Deterministic streaming control (mockApi.streamChat({ hold: true })
  + releaseChat()) replaces wall-clock delays for stop-button and
  streaming-state assertions.
- Selective retries via @flaky tag (retries=0 globally, retries=2 on
  the flaky-chromium project) instead of a global retry budget that
  masks regressions.
- Auto-retrying expect.toHaveAttribute over one-shot getAttribute.
- Coverage opt-in via E2E_COVERAGE=1 wired through monocart-reporter
  with E2E-tier thresholds (50/50/40/25).

Also adds data-testid + aria-label attributes to ~17 frontend
components so the POMs have stable, semantic locators, and a sharded
GitHub Actions workflow (.github/workflows/e2e.yml) with separate
a11y/visual jobs and an opt-in integration job.
Stable, semantic locator contract for the Playwright e2e suite added
in the previous commit. These attributes were dropped from that commit
by an interaction with the pre-commit auto-stash mechanism during a
multi-attempt commit; this commit completes the set so the e2e POMs
have the testids they reference.

Touches ~16 components across chat, collections, drawer, filtering,
layout, and notifications, plus the package.json scripts and the
Playwright run-artifact ignore rules in .gitignore. No behavior
changes — purely additive testid + aria-label attributes.
@otavionvidia otavionvidia changed the title Develop Playwright end-to-end test suite Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant