Sitelet https://github.com/portabletext/editor/pull/3333
Skip to content

feat(racetrack): run Gherkin scenarios against real editors and return JSON evidence - #3333

Draft
christianhg wants to merge 2 commits into
mainfrom
feat/racetrack-pilot
Draft

christianhg wants to merge 2 commits into
mainfrom
feat/racetrack-pilot

Conversation

@christianhg

Copy link
Copy Markdown
Member

Agents proving something about the editor either write a test file or claim. Racetrack gives them a third route: run a Gherkin scenario against real editors and get back what the editors did.

pnpm racetrack run repro.feature --json
pnpm racetrack steps

A run executes the scenario in a Playwright browser through a throwaway vitest test built from the shared editor step definitions, and writes an evidence bundle: checkpoints at Then capture the state and at a failing step (textspec, value, model and DOM selection per editor), every emitted event from editor creation on, console errors, and the outcome. A run only passes with at least one assertion, so capturing state proves nothing by itself. apps/racetrack/README.md covers the bundle, the limits inherited from the step definitions, and the manual path from a passing scenario into gherkin-spec/.

Capture never waits for mutation flushes, so it does not change batching. To record from creation, the test harness gains an internal onTestEditorCreated hook. It does nothing without a listener, and the full editor chromium suite passes with it (193 files).

Racetrack's own unit and e2e tests pin scenario isolation, timeout isolation, failure capture, and the pass rules. Not covered yet: an end-to-end unhandled page error (only the aggregation is unit-tested) and the hook under React strict mode.

Tools built on the test harness had no way to observe an editor from
the start: `createTestEditor` and `createTestEditors` hand the editor
back only after it has rendered and become editable, so a subscription
made then misses `ready` and anything emitted during startup.

`onTestEditorCreated` registers a listener that receives each editor
(named `A`, or `B` for the second editor of `createTestEditors`) from a
plugin mounted as the first child of the provider. Its effect runs
before `EditorProvider` starts the editor, so an `editor.on`
subscription made in the listener sees the startup events. With no
listener registered the plugin does nothing. The hook is internal to
the harness and not exported from any package entry.
…n JSON evidence

Racetrack becomes a harness for agents: `pnpm racetrack run
<file.feature>` runs a scenario against real editors in a Playwright
browser, through a throwaway vitest browser test built from the shared
editor step definitions, and writes an evidence bundle. The bundle holds
checkpoints (textspec, value, model and DOM selection per editor) taken
at `Then capture the state` and at a failing step, a passive log of
every emitted event from editor creation on, console errors, and the
outcome. `passed` requires a completed run with at least one assertion,
so a scenario that only captures state never passes. `pnpm racetrack
steps` prints the step catalogue generated from the definitions.

Checkpoints settle on two animation frames and never wait for mutation
flushes, so capture does not change batching. Each scenario gets its own
step context, a timed-out step marks the remaining scenarios as not run
instead of letting them share a page with it, and failure capture is
best-effort so the original failure and its evidence survive. The
teaser app is removed.
@changeset-bot

changeset-bot Bot commented Sep 27, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 1da6ddd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel

vercel Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
portable-text-editor-documentation Ready Ready Preview Sep 27, 2026 7:47pm UTC
portable-text-example-basic Ready Ready Preview Sep 27, 2026 7:47pm UTC
portable-text-playground Ready Ready Preview Sep 27, 2026 7:47pm UTC

Request Review

@github-actions

github-actions Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Stats

✅ No significant changes.

All scenario measurements (7)

🗺️ @portabletext/editor / @portabletext/editor · @portabletext/editor / @portabletext/editor/behaviors · @portabletext/editor / @portabletext/editor/plugins · @portabletext/editor / @portabletext/editor/selectors · @portabletext/editor / @portabletext/editor/traversal · @portabletext/editor / @portabletext/editor/utils · @portabletext/markdown / @portabletext/markdown · Artifacts

Scenario Kind Bundle (raw / gzip) Gzip change Import time Import change
⚪ @portabletext/editor / @portabletext/editor export 1.06 MB / 135.3 KB None 67 ms -2 ms, -3.2%
⚪ @portabletext/editor / @portabletext/editor/behaviors export 4.0 KB / 147 B None 2 ms -0 ms, -7.0%
⚪ @portabletext/editor / @portabletext/editor/plugins export 5.1 KB / 645 B None 7 ms -0 ms, -0.8%
⚪ @portabletext/editor / @portabletext/editor/selectors export 94.7 KB / 9.3 KB None 8 ms -0 ms, -3.0%
⚪ @portabletext/editor / @portabletext/editor/traversal export 43.5 KB / 4.0 KB None 6 ms -1 ms, -8.7%
⚪ @portabletext/editor / @portabletext/editor/utils export 33.8 KB / 4.1 KB None 6 ms -0 ms, -3.3%
⚪ @portabletext/markdown / @portabletext/markdown export 388.2 KB / 61.8 KB None 27 ms -2 ms, -7.9%

Significant means at least 1.0 KB and 1% gzip, or at least 5 ms and 10% import time.

This branch was successfully deployed

3 active deployments
Preview – portable-text-editor-documentation — 1da6dddd Deployed Sep 27, 2026 by vercel[bot]
Preview – portable-text-playground — 1da6dddd Deployed Sep 27, 2026 by vercel[bot]
Preview – portable-text-example-basic — 1da6dddd Deployed Sep 27, 2026 by vercel[bot]
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