Skip to content

fix(e2e): rewrite insert-modes specs 1/2/4 to JSON data-mode contract - #273

Merged
ErickXavier merged 1 commit into
fix/NOJS-264from
fix/NOJS-265
Jul 10, 2026
Merged

fix(e2e): rewrite insert-modes specs 1/2/4 to JSON data-mode contract#273
ErickXavier merged 1 commit into
fix/NOJS-264from
fix/NOJS-265

Conversation

@ErickXavier

Copy link
Copy Markdown
Collaborator

Summary

  • Rewrote specs 1 (append), 2 (prepend), 4 (sentinel) in insert-modes.spec.ts to mock application/json array responses instead of unsatisfiable text/html fragments
  • Added e2e/examples/insert-prepend-data.html fixture with proper data-mode attributes (as="items", each, template) since the existing insert-prepend.html has no data-mode rendering capability
  • Spec 3 (replace mode) unchanged and still green
  • All 12 tests pass across chromium, firefox, and webkit; 36/36 with --repeat-each=3

What changed

Spec Before After
1 (append) Mocked text/html, asserted data-test="item" divs Mocks application/json array, asserts btn-item template elements, verifies page-1 before page-2 in DOM order
2 (prepend) Mocked text/html, asserted data-test="item" divs, used insert-prepend.html (no as/each/template) Mocks application/json array, uses new insert-prepend-data.html fixture, asserts prepend-item elements, verifies page-2 before page-1 in DOM order
3 (replace) Already JSON Unchanged
4 (sentinel) Mocked text/html, asserted sentinel Mocks application/json array, asserts [data-nojs-sentinel] attached, aria-hidden="true", zero computed height

Test plan

  • E2E_PORT=3999 npx playwright test --config e2e/playwright.config.ts e2e/tests/insert-modes.spec.ts -- 12/12 green
  • --repeat-each=3 -- 36/36 green (no flakiness)
  • Jest unit suite passes (pre-commit hook)

Resolves NOJS-265 (epic NOJS-264)

Specs 1, 2, 4 mocked text/html fragments and asserted raw-HTML divs,
which are unsatisfiable under the data-mode-only get directive contract.
Rewrite all three to mock application/json array responses shaped for
the fixtures' as= keys and assert template-rendered elements:

- Spec 1 (append): JSON items mock, assert btn-item ordering (page 1
  before page 2 in DOM)
- Spec 2 (prepend): new insert-prepend-data.html fixture with proper
  data-mode attributes (as/each/template); assert prepend-item ordering
  (page 2 before page 1 in DOM)
- Spec 4 (sentinel): JSON items mock, assert data-nojs-sentinel
  attachment, aria-hidden, and zero computed height

Add insert-prepend-data.html because the existing insert-prepend.html
has no as= attribute, no each loop, and no template — incompatible with
data-mode rendering. Spec 3 (replace mode) unchanged and still green.

12/12 pass (chromium + firefox + webkit), 36/36 with --repeat-each=3.
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