Skip to content

test: cover CaseStudies' undated-study comparator arms end to end - #1065

Merged
castrojo merged 2 commits into
mainfrom
quality/test-case-studies-undated
Oct 6, 2026
Merged

castrojo merged 2 commits into
mainfrom
quality/test-case-studies-undated

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

sortByPublishedAtDesc compares two case studies through a fallback on each
side, (b.publishedAt || '').localeCompare(a.publishedAt || '')
(src/components/CaseStudies/index.js line 25). All 213 studies in
data/case-studies.json carry a publishedAt, so neither arm can run, and the
empty arm of the date cell beside it (line 204) cannot render.

A missing date is a property of one record rather than a cleared
document-level field, so this uses the additive overlay mechanism
(tests/e2e/fixtures/data/case-studies.json, see
tests/tools/e2e-data-fixtures.cjs) rather than the variant build: the real
studies keep rendering exactly as they did and the undated rows render
alongside them, so the arm is added rather than swapped. npm run build:production and the gating end-to-end job never load the overlay.

The overlay appends two undated studies. A lone undated record only ever
lands on one side of a comparison against the dated ones, leaving the fallback
on the other side unreached — measured at 94.83% with line 25 still listed as
uncovered, because that line carries two regions. With two records the pair is
also compared against each other and both fallbacks run.

tests/e2e/case-studies.spec.js gains one case asserting that each undated row
renders with an empty date cell and its neighbouring cells intact, that the
undated studies occupy the final rows (which is what shows the comparator ran
its fallbacks rather than dropping the rows), and that the other rows still
show a formatted date.

Evidence

Measured at main 900592b by building both coverage sites
(npm run build:e2e:coverage) and running the instrumented suite locally
(npm run test:e2e:coverage with E2E_COVERAGE_DIR/E2E_COVERAGE_RUN_ID
set), then sealing and rendering the report:

regions covered CaseStudies src files
baseline (298 passed) 468 379 92.98%, uncovered [25, 46, 64] 80.98%
this PR (299 passed) 467 380 96.55%, uncovered [46, 64] 81.37%

The baseline render matches job End-to-end coverage of run
37164361552
attempt 1 to within one region (CI 468 / 379 / 80.98%), and CaseStudies is
identical in both.

The result is unchanged under the region fold proposed in #1051
(87.73% -> 88.37% src files, CaseStudies 96.55% either way), so this does
not depend on which of the two lands first and does not touch its files.

The CI gates pass as configured in .github/workflows/ci.yml:
report:e2e:coverage --check-source 100 --check-source-regions 80 --require-source-files exits 0, as do npm run test:unit:coverage:check,
npm run test:unit and npm run check:format.

Not in this PR

The two remaining regions, lines 46 (!data.generatedAt) and 64
(data.caseStudies || []), are document-level fields that an additive overlay
cannot reach. They are out of scope here and called out on the issue.

Related Issue

Closes #1064


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

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

sortByPublishedAtDesc compares through a fallback on each side,
`(b.publishedAt || '').localeCompare(a.publishedAt || '')`. All 213 studies
in data/case-studies.json carry a publishedAt, so neither arm can run and the
empty arm of the date cell beside it cannot render.

A missing date is a property of one record rather than a cleared
document-level field, so this uses the additive overlay mechanism: the real
studies keep rendering exactly as they did and the undated rows render
alongside them, adding the case instead of swapping it.

The overlay appends two undated studies. A lone undated record only ever
lands on one side of a comparison against the dated ones, leaving the
fallback on the other side unreached -- measured at 94.83% with line 25 still
uncovered, because that line carries two regions. With two records the pair
is also compared against each other and both fallbacks run.

End-to-end region coverage for src/components/CaseStudies/index.js goes
92.98% -> 96.55% (uncovered regions [46, 64]) and src files 80.98% ->
81.37%, measured by building both coverage sites and running the instrumented
suite locally (299 passed). The remaining two regions are document-level
fields that an additive overlay cannot reach.

Closes #1064

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

The spec read data/case-studies.json with E2E_COVERAGE forced to '1', so it
always saw the overlaid file and its `test.skip(undated.length === 0)` guard
could never fire. The gating "End-to-end tests" job builds with the real data
and serves 213 studies, so the spec ran there against a page with no undated
row and failed on the row count.

Gate the block on the ambient E2E_COVERAGE instead, the way
tests/e2e/data-fixtures.spec.js gates its own overlay-only assertions, and read
the data file through the ambient environment so the records the spec looks for
are the ones the build it is running against actually rendered.

Verified locally at this head: the gating lane (`npm run build:production` +
`npx playwright test tests/e2e/case-studies.spec.js`) is 7 passed, 1 skipped,
and the coverage lane (`npm run build:e2e:coverage` +
`npm run test:e2e:coverage`) is 299 passed with the spec running. The coverage
report still clears --check-source 100 --check-source-regions 80 with
src/components/CaseStudies/index.js at 100.00% lines / 96.55% regions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: quality <quality@hive.kubestellar.io>
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.

[quality] CaseStudies' undated-study comparator fallbacks have no end-to-end coverage

1 participant