Repository navigation
test: cover MetricsDashboard's single-point Sparkline arm end to end - #1093
Conversation
src/components/MetricsDashboard/index.js line 28 centres a lone sparkline point with the 'values.length === 1 ? 50' arm of its x-coordinate ternary, because the expression beside it divides by values.length - 1. The arm had no end-to-end coverage and no shape in the checked-in data reaches it: data/metrics.json defines exactly two lifecycle trends, submissions with zero values (which returns 'No trend data yet' before the ternary) and publications with five (which takes the other arm). Appending a point to submissions in the ordinary coverage build would not add a case -- submissions is the only trend that reaches the empty-values arm, so it would trade that arm for this one. The point is appended in the variant build instead, the mechanism tests/e2e/data-variants.spec.js documents for exactly this class of branch, so one Playwright run reaches both arms and the report unions them. Closes #1092 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <quality@hive.kubestellar.io>
|
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 Hive will keep the |
|
CI note: runs 37363814397 (Validate repository) and 37363814525 (CodeQL) on the current head ( The agent tier cannot re-run jobs ( 🐝 Hive Agent: — hive: agent=ci-maintainer backend=copilot model=kimi-k3 copilot=1.0.88 |
Test Improvement
Covers the
values.length === 1 ? 50arm of the x-coordinate ternary inSparkline(src/components/MetricsDashboard/index.jsline 28) — the arm thatcentres a lone data point, because the expression beside it divides by
values.length - 1and would be a division by zero.No shape in the checked-in data reaches it.
data/metrics.jsondefines exactlytwo lifecycle trends:
submissionscarries zero values, soSparklinereturnsNo trend data yetbefore reaching the ternary at all, andpublicationscarries five, which takes the arm beside it.
Why the variant build
tests/e2e/fixtures/data/**overlays are additive — the extra record rendersalongside the real ones and nothing already covered stops rendering. Appending
a point to
submissionsin the ordinary coverage build is not additive in thatsense:
submissionsis the only trend that reaches the empty-values arm, sogiving it a point would trade that arm for this one rather than add a case.
The point is appended in
tests/e2e/fixtures/data-variants/metrics.jsoninstead, the mechanism
tests/e2e/data-variants.spec.jsalready documents forthis class of branch. One Playwright run then visits
/metricsand/e2e-coverage-variant/metricsand the report unions what each build reached,so both arms end up covered.
What this adds
tests/e2e/fixtures/data-variants/metrics.json— one appended point onreferenceArchitectureLifecycle.trends.submissions.values, beside theexisting
generatedAtclearing. The overlay'sappendpath must alreadyexist in the real file, so a regenerated
data/metrics.jsonthat drops thetrend fails the build rather than silently losing the coverage.
tests/e2e/metrics-sparkline-variant.spec.js— two cases, skipped outsideE2E_COVERAGE=1. The real route asserts the premise (one trend empty, nonesingle-point,
No trend data yetrendered); the variant route asserts thelone point is centred. Both read the trends through
loadSiteData()ratherthan hard-coding a label or a number, so an edited overlay fails here instead
of leaving a test that asserts nothing. The variant case also asserts the
other trend still has more than one point, so the variant does not quietly
trade one uncovered region for another.
No change to any file under
src/.Evidence
E2E, before — CI artifact
e2e-coverageid11348560988, run37317061554,
job
End-to-end coverage,mainat8afaa67(this branch's base):{"file":"src/components/MetricsDashboard/index.js","regions":44,"coveredRegions":38,"regionPercent":86.36,"uncoveredRegions":[28,65,76,85,124,174]}.Rendered output, after —
npm run build:e2e:coverage:variantat thisbranch's head, then reading the two built pages. Inside
section[aria-labelledby="lifecycle-title"]:No trend data yetpointsbuild/metrics(real)Trend from 2024-11 to 2026-070,4 25,… 100,…build/e2e-coverage-variant/metricsTrend from 2026-01 to 2026-01,Trend from 2024-11 to 2026-0750,4,0,4 25,… 100,…points="50,4"is the arm under test: a single pair, x at the centre of the0 0 100 24viewBox rather than an index-derived offset. It is what the newspec asserts, computed from the overlaid value rather than written as a
literal.
npm run test:unit:coverage:checkexits 0 — the overlay change leavestests/e2e-data-fixtures.test.mjspassing, includingthe variant build clears the fields the ordinary build keeps, sincegeneratedAtis still cleared tonull.npx prettier --checkclean on both changed files.npx playwright test --listcollects both cases.Playwright itself was not run locally: this environment has no root and
chrome-headless-shellcannot loadlibglib-2.0.so.0, so the browser will notlaunch here. The assertions were instead verified against the SSR markup of the
two builds above, which is the same DOM the hydrated page asserts on. CI's
End-to-end coveragejob is the authority on the resulting region count.Related Issue
Closes #1092
Coordination
Touches exactly two files —
tests/e2e/fixtures/data-variants/metrics.jsonandthe new
tests/e2e/metrics-sparkline-variant.spec.js— and one function undertest,
Sparklineinsrc/components/MetricsDashboard/index.js.Disjoint from every open hold-gated PR. In particular it does not edit
tests/e2e/data-variants.spec.jsortests/e2e-data-fixtures.test.mjs, where#1034 and #1078 are working, which is why the cases live in a new spec file
rather than beside the existing variant-build cases; #1034's variant overlay is
community-people.json, a different file in the same directory. It does nottouch
tests/e2e/data-fixtures.spec.js(#1054), the e2e reporter cluster(#1040, #1070),
tests/svg-active-content.test.mjs(#1088, #1090),scripts/fetch-community-people.mjs(#1085), or the component specs #1058,#1060, #1065, #1075, #1081, #1083.
The
--check-source-regionsfloor in.github/workflows/ci.ymlis notre-derived here: this change only raises the covered-region count, so the
existing floor still holds, and that path cannot be pushed by this lane in any
case.
— hive: agent=quality backend=copilot model=claude-opus-5 copilot=1.0.88