Skip to content

test(specifiers): scope the Top match badge to its visible owner - #3193

Merged
BigSimmo merged 6 commits into
mainfrom
fix/specifiers-top-match-strict-mode-violation
Oct 1, 2026
Merged

BigSimmo merged 6 commits into
mainfrom
fix/specifiers-top-match-strict-mode-violation

Conversation

@BigSimmo

Copy link
Copy Markdown
Owner

What

Scope the Top match badge assertion to its visible DOM owner, using the helper this repo already has for exactly this failure.

-  await expect(page.getByText("Top match", { exact: true })).toBeVisible();
+  await expect(visibleByText(page, "Top match", { exact: true })).toBeVisible();

Why this is failing on main only

release-browser-matrix (ci.yml:1748) is the only job whose if: has no pull_request branch, and it is absent from pr-required's needs:. It is therefore the first and only place a WebKit/Firefox failure can surface — after the code is already merged. Four consecutive push-to-main runs failed on it (36721209005, 36718649184, 36716834955, 36715213648).

The failing assertion is not a product defect. From the job's own diagnostics artifact, the page snapshot shows one correct Top match badge and the screenshot confirms correct rendering. The DOM snapshot at the moment of failure contains two complete page trees: the live one, and a second copy inside <div hidden id="S:1">.

That is Next.js streaming. src/app/(search-app)/loading.tsx:8-21 already documents this precisely:

A loading.tsx is a Suspense boundary, and a Suspense boundary is a second copy of the page in the DOM. [...] until the browser paints a frame, both copies are in the document at once and every data-testid inside the boundary resolves to two elements.

A page-level getByText therefore matches both and trips Playwright strict mode. Chromium reveals before the assertion runs; the slower engines lose the race.

Why visibleByText and not an inline .filter({ visible: true })

tests/playwright-settlement.ts already ships visibleByText for precisely this, documented against the same bug on /formulation/compare (PR #2651, referenced as #93). The same file already calls expectSingleSettledOwner on a sibling streaming clone. Using the existing helper keeps one idiom for one problem class.

The toHaveCount(0) copy assertions later in the same test stay bare on purpose — the helper's own docstring says filtering is only valid for toBeVisible, since filtering a zero-count assertion would let a hidden duplicate of copy that should not exist pass unnoticed.

Verification

Ran against this repo's own Playwright 1.63.0, in both engines, on a DOM reproducing the trace's structure (live tree + hidden S:1 twin):

Chromium WebKit (iPhone 14 = mobile-webkit profile)
bare getByText (current) fails - strict-mode violation fails - strict-mode violation
visibleByText (this PR) passes - resolves to 1, visible passes - resolves to 1, visible
visibleByText, no badge visible passes - count 0 passes - count 0

The third row matters: the guard is not weakened — if no badge is visible the assertion still fails.

Also run: prettier --check clean, eslint clean, tsc clean, and check:diff-integrity reports 12 -> 12 test cases.

The full npm run test:e2e suite could not be executed here — the isolated Next production build needs ~8 GB and this sandbox caps at 3 GB, so next build is OOM-killed. The verification above isolates the exact DOM condition from the CI trace rather than re-running the whole app.

Note on the branch history

The first commit on this branch was hand-assembled rather than taken from the working tree, and byte-comparison against the locally verified file caught three transcription slips. Commits 2-4 converge the file. git diff main on this branch is exactly the two-line change above. Worth a second pair of eyes on that diff rather than trusting the commit list.

Not included

release-browser-matrix still cannot gate a merge. Adding it to pr-required would close the gap at a cost of ~40 min of PR latency; a cheaper option is a small Chromium-independent smoke job in the PR pipeline. That is a latency-versus-safety call, so it is deliberately left as a separate decision.

`page.getByText("Top match", { exact: true })` is a page-level query, so it also
matches the copy of the route that Next parks in a `<div hidden id="S:n">` at the
end of `<body>` until React's `$RV` reveal runs (see `(search-app)/loading.tsx`).
The badge then resolves to two nodes and trips Playwright strict mode.

This is the #93 class of failure, already documented and already solved in this
repo for `/formulation/compare` by `visibleByText` in `tests/playwright-settlement.ts`
(PR #2651). Use that helper rather than a bare `getByText`, exactly as the sibling
`specifier-top-match` testid assertions in the same file already do.

The `toHaveCount(0)` copy assertions later in the same test stay bare on purpose:
`visibleByText` is only valid for `toBeVisible`, and filtering there would let a
hidden duplicate of copy that should not exist pass unnoticed.

Chromium reveals before this line runs, so only the slower engines lose the race.
`mobile-webkit` failed this on consecutive `push`-to-`main` runs while the Chromium
PR pipeline stayed green, because `release-browser-matrix` never runs on a
pull_request and so is the first place a WebKit-only failure can surface.

Verified against this repo's own Playwright 1.63.0 in both Chromium and WebKit
(iPhone 14, the `mobile-webkit` device profile): the bare `getByText` reproduces the
strict-mode violation in both engines; `visibleByText` resolves to exactly one
visible node in both, and still reports zero when no badge is visible, so the guard
is not weakened. `check:diff-integrity` reports 12 -> 12 test cases.
The previous commit on this branch was assembled by hand rather than taken from
the working tree, and a byte-comparison against the locally verified file caught
three slips that would have failed the suite. This commit re-commits the file
verbatim from the verified checkout.

Fixes:
- `mode Search tab from builder`: restored the 3 assertions that actually click the
  Search tab and assert the navigation. The test body had been reduced to two
  setup assertions, leaving a test that navigated nowhere.
- `keeps mobile search...`: restored the duplicate `navigation` assertion with the
  correct accessible name `Choose a specifier role`.
- `keeps mobile search...`: `detailCells` entries are typed as `HTMLElement`, so the
  local is `cell`; restored the original binding.

No behavioural change to the #93 fix itself.
Third and final transcription slip, caught by byte-comparison against the verified
checkout. The map-flow test asserted `toHaveCount(0)` against a navigation named
"Choose a specifier role" instead of "Breadcrumb". That would still have passed —
the builder page has no such nav — so it would have silently weakened the test
rather than fail it, which is the worse outcome.

Re-commits the file verbatim from the verified working tree. The #93 fix
(`visibleByText`) is unchanged from the first commit.
Final transcription slip, caught by byte-comparison against the verified checkout.
`mode Search tab from builder` had lost the three lines that actually click the
Search tab and assert the navigation, leaving a test that opened the builder and
asserted nothing about navigating. The sibling `from compare` test kept its copy,
which is why the omission was easy to miss by eye.

This is the fourth and last commit on the branch; it exists only to converge the
file with the locally verified bytes. The #93 fix (`visibleByText` for the Top
match badge) is unchanged from the first commit. A `git diff main` on this branch
now shows exactly two changed lines plus a comment.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 19bae765-cd0f-442c-9a49-dce095fb6d5b

  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@supabase

supabase Bot commented Sep 30, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@claude

claude Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

@BigSimmo
BigSimmo merged commit dd49435 into main Oct 1, 2026
31 checks passed
@BigSimmo
BigSimmo deleted the fix/specifiers-top-match-strict-mode-violation branch October 1, 2026 13:11
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