Skip to content

test(e2e): Playwright harness + regression test for editor scroll alignment#14

Merged
BorisTyshkevich merged 1 commit into
mainfrom
test/e2e-editor-alignment
Jun 22, 2026
Merged

test(e2e): Playwright harness + regression test for editor scroll alignment#14
BorisTyshkevich merged 1 commit into
mainfrom
test/e2e-editor-alignment

Conversation

@BorisTyshkevich

Copy link
Copy Markdown
Collaborator

Why

The editor highlight/selection alignment bug (just fixed on main, c7f618c) is a render-layer defect: a long line gives the <textarea> a horizontal scrollbar that shrinks its clientHeight, so the highlight <pre> (no scrollbar) clamps behind the selection when scrolled to the bottom. happy-dom has no real layout or scrollbars, so the unit suite can't reproduce it — and it regressed twice. This adds a minimal real-browser layer for that class of bug.

What

  • playwright.config.js — serves the repo over python3 -m http.server so the harness imports the actual src/ modules as native ESM (no bundling, always current); Chromium.
  • tests/e2e/editor.html — mounts the real editor with a tiny stub controller.
  • tests/e2e/editor-alignment.spec.js — loads a tall query whose last line forces a horizontal scrollbar, scrolls to the bottom, and asserts the textarea and highlight keep equal client boxes and the same scroll offset.
  • package.json@playwright/test devDep + npm run test:e2e. Kept separate from npm test and the coverage gate. vitest only globs tests/unit/**/*.test.js, so it ignores these specs.
  • README + .gitignore (/test-results/, /playwright-report/) updated.

Validation

Verified in a real engine (no bundled-browser download needed for the check):

  • With the fix: clientHeight 340 == 340, scrollTop 365.83 == 365.83 → both assertions pass.
  • Pre-fix state (scrollbar restored): clientHeight 326 vs 340, scrollTop 379.58 vs 365.83 → both assertions fail.

So the test genuinely catches the regression.

Note

The sandbox blocks cdn.playwright.dev, so npx playwright install chromium can't run here; CI / other machines install it normally (documented in the config + README). Unit suite unaffected — npm test still green (408 tests).

🤖 Generated with Claude Code

https://claude.ai/code/session_01QennTvGKAtJZrv9EpQagef

…ll alignment

happy-dom has no real layout or scrollbars, so the editor highlight/selection
alignment bug (a textarea scrollbar shrinking its client box, clamping the
highlight <pre> behind the selection on scroll) couldn't be caught at the unit
layer — it regressed twice. This adds a minimal real-browser layer for exactly
that class of bug.

- playwright.config.js: serves the repo over python http.server so the harness
  imports the *actual* src/ modules as native ESM (no bundling); chromium.
- tests/e2e/editor.html: mounts the real editor with a stub controller.
- tests/e2e/editor-alignment.spec.js: loads a tall query whose last line forces
  a horizontal scrollbar, scrolls to the bottom, and asserts the textarea and
  highlight keep equal client boxes and the same scroll offset. Verified the
  assertions fail on the pre-fix state and pass on the fix (negative-checked in
  a real engine).
- package.json: @playwright/test devDep + `npm run test:e2e`. Separate from
  `npm test` and the coverage gate.
- README + .gitignore updated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QennTvGKAtJZrv9EpQagef
@BorisTyshkevich BorisTyshkevich merged commit 516b146 into main Jun 22, 2026
2 checks passed
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