Skip to content

test: consolidate coverage around public API workflows with Vitest - #45

Merged
francoischalifour merged 9 commits into
mainfrom
fc/public-api-test-basis
Oct 8, 2026
Merged

francoischalifour merged 9 commits into
mainfrom
fc/public-api-test-basis

Conversation

@francoischalifour

@francoischalifour francoischalifour commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Why

The existing suite split behavioral testing between Bun tests and Playwright Test. Many tests imported private modules, fabricated internal state, or asserted implementation details. This made refactoring expensive and distributed the testing conventions across several mechanisms.

The goal is a simpler foundation: only high-level public API tests, run with Vitest. Tests should describe what an app author, host integration, or reader can do with the package, and verify the results they observe.

For example, a filter change should prove that the displayed results, inspection evidence, and exported data remain consistent during refresh and failure. It should exercise the public client and view APIs rather than populate a query cache or construct an internal view state.

Architecture

Replace the separate behavioral runners with one Vitest configuration and one command:

bun run test

Non-browser workflows run in Node against the built package. Browser workflows use the Playwright library to launch real Chromium from Vitest. Each browser test receives a fresh context, and fixture servers use automatically assigned ports.

Tests import the package through @altertable/data-app/<entry>. Data, authorization decisions, and failures enter through public dependency injection. Lint rules prohibit private source imports and the retired test runners.

Keep typechecking, linting, packaging, and starter validation as explicit checks. bun run check builds the package and runs the complete verification sequence.

Public behavior covered

The replacement suite exercises:

  • Operations and delivery: input/output validation, authorization, HTTP and message routing, SQL evidence, safe error disclosure, response limits, cancellation, and deadlines.
  • App authoring: hosted and local startup, filters, loading, empty results, refresh, retry, retained results, independent sections, and client isolation.
  • Binding ownership: rejection of another same-shaped view’s dataset, metric, export, or story evidence, alongside a successful workflow using the owning view.
  • Reader workflows: table search and pagination, formatting, CSV and ZIP downloads, presentations, fullscreen behavior, and inspection.
  • Controlled inspection: opening and closing requests notify the owner and wait for approval before changing the dialog.
  • Iframe hosting: URL and bundle sources, navigation persistence, concurrent requests, overload protection, cancellation recovery, disposal, stale-session rejection, and foreign-message rejection.
  • Failure handling: runtime and bootstrap failures, recovery, logger failure isolation, and malformed-log rejection. Logger invocation counts are observed before fixture filtering.
  • Browser presentation: phone and desktop layouts across request states, explicit CSP-compatible stylesheet installation, and document isolation.
  • Mobile interaction: a touch-enabled phone journey covering filters, comparisons, calendar dismissal, inspection, and state persistence after reload.

Ordinary iframe workflows use a longer deadline. The timeout workflow explicitly selects a short deadline so cancellation tests do not race an unrelated timeout.

Organization and maintenance

Organize browser tests by consumer capability: authoring, embedding, export, presentation, reports, runtime, and views.

Prefer queries by role and accessible name for controls, headings, regions, dialogs, and feedback. App-owned calculation results use labelled native <output> elements. Retain scoped text queries for prose and empty-state copy without a meaningful role.

Move gallery and playground assets into dev, keeping development examples separate from test fixtures. Update contributor setup, CI, and desktop actions to use the unified suite, including installing Chromium before running checks.

Verification

Integrated the latest main, including annotations and the authored styling contract. Annotation workflows cover screenshot-backed feedback, host rejection and retry, retained displayed input, and host-owned drafts across iframe replacement. Public appearance overrides run in the same Vitest suite; source/style integrity remains an explicit tooling check.

bun run check and bun run check:workflows pass locally: 130 tests across 15 files, plus packed-consumer and starter validation.

Exercise operation definition, authorization, HTTP delivery, validation,
and query evidence through published package entries. Keep setup local
to one consumer workflow.

Make Vitest the default test command and preserve existing Bun coverage
in required checks during the incremental migration.
Replace the Bun and Playwright Test suites with one Vitest configuration
and command. Exercise supported package entries through operation, HTTP,
message, Worker, and real Chromium app workflows; remove private state,
protocol-helper, markup, and CSS implementation tests.

Reuse the public runtime workflows against the npm archive. Retain public
consumer type checks, enforce public test imports, and preserve the
gallery and playground under dev. Update CI and desktop actions to run
the unified suite.

Verified with bun run check (102 tests), including Chromium, packed
consumer and starter checks, plus bun run check:workflows.
Protect consumer guarantees omitted when consolidating the test suite: readable phone and desktop layouts throughout real request transitions, formatting edge cases in rendered reports, explicit nonce-compatible stylesheet installation per document, and logging failure isolation and spoof rejection.

Exercise bridge overload, cancellation recovery, and transport disposal through an actual iframe. Keep all behavioral checks in the existing public Vitest suite, with no private imports or new test runner.

Validation: bun run check passes, including 109 tests across seven files and packed-consumer and starter checks.
Split app workflows by authoring, export, presentation, views, reporting, embedding, and runtime behavior so each consumer capability can be reviewed and run independently with the existing Vitest browser fixture.

Prefer roles and accessible names for headings, controls, feedback, and regions. Render app-owned calculation results as labelled native outputs, replacing test IDs and result selectors. Retain scoped text queries for prose without a meaningful role, and document the query and organization conventions for contributors.

Validation: bun run check passes, including all 109 tests across 13 files, packed-consumer checks, and starter checks.
Exercise controlled inspection opening and closing requests before owner approval, and observe all host logger invocations before filtering so malformed delivery cannot evade assertions.

Render same-shaped views through public APIs and reject foreign datasets, metrics, exports, and story evidence while retaining a successful owned-view workflow. Give ordinary iframe requests a ten-second deadline and select the one-second deadline only in the timeout workflow to avoid cancellation races.

Validation: focused browser workflows and bun run check pass, including 115 tests across 13 files, packed-consumer checks, and starter checks.
Restore mobile interaction coverage alongside viewport layout checks with a targeted Chromium phone context using mobile and touch emulation. Exercise region selection, comparison controls, outside-tap calendar dismissal, inspection opening and closing, and filter persistence after reload through accessible queries and touch actions.

Add viewport metadata to the consumer fixture so the emulated phone uses its actual screen width. Keep the existing Vitest runner and browser fixture lifecycle.

Validation: focused mobile workflow and bun run check pass, including 116 tests across 13 files, packed-consumer checks, and starter checks.
@albert20260301

Copy link
Copy Markdown

@francoischalifour #45 currently conflicts with main, and only the title check has completed on this head. Please rebase onto current main and resolve the conflict before review so the required package and browser suite can run against the resolved test migration.

Resolve the main merge while preserving one public Vitest suite. Keep annotation client and routing workflows, add screenshot-backed browser feedback and retry coverage, preserve displayed input during refresh, and exercise public appearance overrides.

Keep developer fixtures under dev and source/style integrity checks under check:styles, rather than reintroducing Bun or Playwright Test runners. Preserve main’s annotation and styling implementations and development-server reload behavior.

Validation: bun run check and bun run check:workflows pass, including 130 tests across 15 files, packed-consumer checks, and starter checks.
@francoischalifour
francoischalifour merged commit 50f40b3 into main Oct 8, 2026
7 checks passed
@francoischalifour
francoischalifour deleted the fc/public-api-test-basis branch October 8, 2026 08:54
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.

3 participants