Skip to content

test: fold out phantom e2e coverage regions over covered lines - #1051

Merged
mrbobbytables merged 1 commit into
mainfrom
quality/e2e-region-phantoms
Oct 5, 2026
Merged

mrbobbytables merged 1 commit into
mainfrom
quality/e2e-region-phantoms

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

getRegionCoverage in tests/tools/e2e-coverage-report.mjs keeps one entry per
branch location v8-to-istanbul emits, and v8-to-istanbul derives those
locations from generated block boundaries mapped back through the source
map. Minified output carries no mapping at most boundaries, so an endpoint
snaps to whatever mapping precedes it, and a generated block that never ran is
reported as an original span that demonstrably did.

This adds isPhantomRegion and filters those spans out before the per-file
counts are taken: a multi-line zero-count region whose every
statement-carrying line is covered in the union is dropped. Single-line regions
are untouched — several of them share one line and the per-line fold cannot
tell them apart, which is the whole reason regions are measured.

tests/e2e-coverage-report.test.mjs gains one regression test driving the union
with two artifacts: one page covers every line, a second contributes a
zero-count block over covered lines 1-3 and a second one closing on line 5,
which nothing ran. The first folds out; the second and the line-5 region stay
and keep their weight in the denominator. The test fails on main
(uncoveredRegions [1, 4, 5] instead of [4, 5]).

Evidence

Reproduced at 900592b by building and running the suite locally
(npm run build:e2e:coverage, then npm run test:e2e:coverage with
E2E_COVERAGE_DIR/E2E_COVERAGE_RUN_ID set, 298 passed) and rendering the
report. The local render matches job End-to-end coverage of run
37164361552
attempt 1 to within one region: CI 468 regions / 379 covered / 80.98%, local
467 / 378 / 80.94%, and src/components/hooks/useFocusTrap.js identical in
both at 27 regions / 17 covered / 62.96%, uncovered region lines
[18, 28, 33, 35, 38, 40, 48, 51].

Dumping every region key for that file over the local run:

36:6:38:24  count=10
36:6:40:21  count=1
38:24:40:21 count=0     <-- reported uncovered
40:18:41:70 count=10
40:18:43:22 count=0

while statement coverage over the same union puts lines 38, 39 and 40 at 1.

With the fold applied, over the same run: 37 of 467 regions removed,
src files 80.94% -> 87.91%, useFocusTrap 62.96% -> 85.00% with uncovered
regions [33, 35, 51] — three genuine single-line short-circuit arms, and
lines 18, 28, 38, 40 and 48 gone.

npm run test:unit:coverage:check and npm run check:format pass;
tests/tools/e2e-coverage-report.mjs region coverage goes 90.68% -> 91.03%.

Correction to the issue's hypothesis

The issue hypothesised that useFocusTrap is bundled into several chunks and
that per-chunk column drift splits one branch into two keys. That is refuted:
the near-duplicate keys appear within a single chunk (c1ce2b9c.8f0a7cfe.js
alone carries 36:6:38:24, 36:6:40:21 and 38:24:40:21), and the three
chunks carrying the file agree on their keys exactly. Keying the union by
line-plus-ordinal, as the issue suggested, would not have fixed anything.

Not in this PR

--check-source-regions is set in .github/workflows/ci.yml, which this lane
cannot push. The exact replacement line and its justification are on the issue;
the floor is unchanged here and the gate stays green either way, because the
number only rises.

Related Issue

Refs #1035 (needs-human: the --check-source-regions floor lives in
.github/workflows/ci.yml, which this lane's token cannot push; re-deriving it
from the corrected number needs a human or an ISSUES_PRS_MERGE agent)


Filed by quality agent (hold-gated mode). Human review required.

— hive: agent=quality backend=copilot model=claude-opus-5 copilot=1.0.88

getRegionCoverage keeps one entry per branch location v8-to-istanbul
emits, and v8-to-istanbul derives those locations from *generated* block
boundaries mapped back through the source map. Minified output carries no
mapping at most boundaries, so an endpoint snaps to whatever mapping
precedes it and a block that never ran is reported as an original span
that demonstrably did.

At 900592b the report put src/components/hooks/useFocusTrap.js at 62.96%
with a zero-count region across lines 38-40 -- the Shift+Tab wrap arm that
tests/e2e/interactions.spec.js:217 presses and asserts -- while the same
union put statement coverage for lines 38, 39 and 40 at 1. A span cannot
go unexecuted while every line it covers executed, so multi-line
zero-count regions whose every statement-carrying line is covered are no
longer counted. Single-line regions are untouched: several of them share
one line and the per-line fold cannot tell them apart, which is the whole
reason regions are measured.

Over a full local coverage run the fold removes 37 of 467 regions and
lifts src files from 80.94% to 87.91%; useFocusTrap goes to 85.00% with
only its three genuine single-line arms left.

Signed-off-by: quality <quality@hive.kubestellar.io>
@hivecommons-hive hivecommons-hive Bot added the hold label Oct 4, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Important

Held for human review by the hive's ACMM level gate.

This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Non-outreach agents are held at ACMM L3–L5; the outreach agent is always held because it publishes project-facing communication.

Hive will automatically remove the hold label once current policy no longer requires a level hold for "quality". If this is an outreach PR, a human must review it and remove the label.

This was referenced Oct 4, 2026
@mrbobbytables
mrbobbytables added this pull request to the merge queue Oct 5, 2026
Merged via the queue into main with commit 24a1f61 Oct 5, 2026
7 checks passed
@mrbobbytables
mrbobbytables deleted the quality/e2e-region-phantoms branch October 7, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant