test(editor): scope createTestEditor's returned locator to the rendered editor#2644
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Contributor
📦 Bundle Stats —
|
| Metric | Value | vs main (703e4a9) |
|---|---|---|
| Internal (raw) | 745.0 KB | - |
| Internal (gzip) | 143.0 KB | - |
| Bundled (raw) | 1.35 MB | - |
| Bundled (gzip) | 304.0 KB | - |
| Import time | 98ms | +1ms, +0.6% |
@portabletext/editor/behaviors
| Metric | Value | vs main (703e4a9) |
|---|---|---|
| Internal (raw) | 467 B | - |
| Internal (gzip) | 207 B | - |
| Bundled (raw) | 424 B | - |
| Bundled (gzip) | 171 B | - |
| Import time | 3ms | +0ms, +2.2% |
@portabletext/editor/plugins
| Metric | Value | vs main (703e4a9) |
|---|---|---|
| Internal (raw) | 3.3 KB | - |
| Internal (gzip) | 948 B | - |
| Bundled (raw) | 3.1 KB | - |
| Bundled (gzip) | 878 B | - |
| Import time | 8ms | +0ms, +0.3% |
@portabletext/editor/selectors
| Metric | Value | vs main (703e4a9) |
|---|---|---|
| Internal (raw) | 76.3 KB | - |
| Internal (gzip) | 14.3 KB | - |
| Bundled (raw) | 72.5 KB | - |
| Bundled (gzip) | 13.3 KB | - |
| Import time | 8ms | -0ms, -1.1% |
@portabletext/editor/traversal
| Metric | Value | vs main (703e4a9) |
|---|---|---|
| Internal (raw) | 9.2 KB | - |
| Internal (gzip) | 2.4 KB | - |
| Bundled (raw) | 9.3 KB | - |
| Bundled (gzip) | 2.4 KB | - |
| Import time | 5ms | +0ms, +0.9% |
@portabletext/editor/utils
| Metric | Value | vs main (703e4a9) |
|---|---|---|
| Internal (raw) | 30.6 KB | - |
| Internal (gzip) | 6.5 KB | - |
| Bundled (raw) | 28.5 KB | - |
| Bundled (gzip) | 6.1 KB | - |
| Import time | 7ms | +0ms, +0.5% |
🗺️ . · ./behaviors · ./plugins · ./selectors · ./traversal · ./utils · Artifacts
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
This was referenced May 11, 2026
c5f032d to
c063ec0
Compare
createTestEditor's returned locator to the rendered editorcreateTestEditor's returned locator to the rendered editor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
createTestEditorfrom@portabletext/editor/test/vitestmounts the editor throughvitest-browser-react'srender(), which returns a locator scoped to the freshly-mounted container. It then discarded that scoped locator and reached forpage.getByRole('textbox')instead.Two calls in the same DOM expose the bug. The second call's
page.getByRole('textbox')matches both editors in document order, returns the first match, so the second locator addresses the first editor instead of its own. Vitest's iframe-per-test isolation hid this in CI; embedders running multiple editors in the same DOM (a Sanity Studio form with two PT inputs, an integration host with a playground next to a test target, anything driven by Playwright that doesn't iframe each scenario) trip it.Fix is one line: use the scoped locator that
render()already returned.The accompanying regression test mounts two editors, types into each, and asserts each editor ends up with its own content. The test fails on
mainbecause the second editor's locator targets the first, so the seconduserEvent.typewrites into the first editor and the second editor's snapshot stays empty.createTestEditors(plural) already scopes bydata-testidper-editor; nothing changes there.