Skip to content

test: cover the CaseStudies render contract and its filter behaviour - #466

Merged
mrbobbytables merged 1 commit into
mainfrom
quality/test-case-studies
Sep 22, 2026
Merged

mrbobbytables merged 1 commit into
mainfrom
quality/test-case-studies

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds tests/case-studies.test.mjs (new file; no production code touched).

src/components/CaseStudies/index.js was never imported by any test — it did not appear in the node --test --experimental-test-coverage table at all. Its filter predicate (filterCaseStudies) and facet option builder (useCaseStudyFilterOptions) are module-private, so rendering the component is the only way to reach them.

The test imports the component through the existing tests/helpers-jsx.mjs tooling and tests/tools/react-element-tree.mjs, and drives useState/useMemo through React's per-render dispatcher slot with a small local driver kept inside the test file. It deliberately does not touch tests/tools/react-hook-driver.mjs, which #435 is extending.

16 tests assert:

  • one table row per entry in data/case-studies.json, and the matching results-bar text
  • each row links to study.url with target="_blank" + rel="noreferrer", and its cells join projects/industries/countries
  • scope="row" on every row header and the four column headings
  • each <select> offers exactly the deduplicated, sorted facet values in the data, behind an empty-valued placeholder
  • every control has a <label for=...> bound to its id
  • the query filter is case-insensitive, trims surrounding whitespace, and a whitespace-only query is not an active filter
  • each select narrows the table, and the three filters intersect rather than union
  • an unmatchable query renders the empty state with zero rows; the empty state is absent while rows match
  • Clear filters renders only while a filter is active and resets all four controls
  • SyncStatus renders the data.sourceUrl credit with rel="noreferrer" and the formatted generatedAt date
  • aria-label="CNCF case studies" on the region and aria-live="polite" on the count

Coverage

src/components/CaseStudies/index.js: absent from the report → 100.00% lines, 100.00% functions, 94.59% branches.

Full suite on this branch: npm run test:unit — 610 pass, 0 fail (594 on main at 0fd5f8b), Node v26.8.1. npx prettier --check tests/case-studies.test.mjs is clean.

Files claimed by this PR

tests/case-studies.test.mjs only. Disjoint from every open hold-gated PR: #435 (tests/architecture-filters-ui.test.mjs, tests/tools/react-hook-driver.mjs), #443 (tests/metrics-dashboard.test.mjs), #453 (tests/awards-timeline.test.mjs), #458 (tests/radar-reports.test.mjs), #460 (tests/footer.test.mjs, tests/jsx-hooks.test.mjs, tests/tools/jsx-hooks.mjs), #446, #437, #455, #225.

Related Issue

Closes #465


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

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

src/components/CaseStudies/index.js was never imported by any test, so it
did not appear in the node --test coverage report at all. Its filter
predicate and facet option lists are module-private, so the only way to
reach them is to render the component.

Add tests/case-studies.test.mjs, which imports the component through the
existing tests/helpers-jsx.mjs tooling and drives useState/useMemo through
React's dispatcher slot. It asserts the table rows against the real
data/case-studies.json, the deduplicated and sorted select options, the
case-insensitive and whitespace-trimming query filter, filter
intersection, the empty state, the Clear filters gate and reset, the
labelling and aria-live contract, and rel=noreferrer on every outbound
link including the sync-status credit.

Coverage of the component goes from absent to 100% lines / 100% functions
/ 94.59% branches. No production code changes.

Signed-off-by: kubestellar-hive[bot] <kubestellar-hive@hive.kubestellar.io>
@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.

@hivecommons-hive hivecommons-hive Bot added quality Approved by a Hive merger/owner for auto-merge on green CI testing Approved by a Hive merger/owner for auto-merge on green CI agent/quality Approved by a Hive merger/owner for auto-merge on green CI hive/hosted-available-lke648397-260827-5n31 labels Sep 22, 2026
@mrbobbytables
mrbobbytables added this pull request to the merge queue Sep 22, 2026
Merged via the queue into main with commit 3dc88ea Sep 22, 2026
2 checks passed
@mrbobbytables
mrbobbytables deleted the quality/test-case-studies branch September 25, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent/quality Approved by a Hive merger/owner for auto-merge on green CI hold quality Approved by a Hive merger/owner for auto-merge on green CI testing Approved by a Hive merger/owner for auto-merge on green CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] src/components/CaseStudies/index.js has zero unit coverage (filter predicate, option lists, empty state, sync-status link)

1 participant