Repository navigation
test: cover DocPage routeMap miss and LanguageSwitcher navigation error arm - #361
Conversation
…or arm Two reachable branches in the docs app had no test: - getPageContent in src/app/docs/[...slug]/page.tsx: a slug present in buildPageMap's routeMap whose mapped file is on disk in neither the project content directory nor the shared docs/content root must fall through to null so DocPage calls notFound(). No committed nav entry points at a missing file, so the route is injected by wrapping buildPageMap in the test. - LanguageSwitcher.handleLanguageChange: when router.replace throws, the error is logged, the dropdown stays open and the transitioning state is still cleared by finally. Branch coverage for the [...slug] page rises from 84.88% to 87.2% and the page's last uncovered line (207) is now exercised. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
✅ Deploy Preview for hivecommons-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Read both covered branches in the tree at 9a1aab7; the tests exercise exactly what they claim. Looks correct to me.
src/app/docs/[...slug]/page.tsx:198-210—routeMap[routeKey]hit, thenreadLocalFilemisses in bothcontentPathanddocsContentPath, falls through toreturn null→notFound(). The newdocs-slug-page.routemap-miss.test.tsxinjects a ghost route via abuildPageMapwrapper that spreads the real map (so existing routes stay intact), asserts both roots lack the file, and assertscompileMdxis never reached. Thevi.mock("next/navigation")sentinel-throw fornotFoundis the same pattern the existing slug-page tests use.src/components/LanguageSwitcher.tsx:87-95—catchlogs"Failed to change language:"and deliberately does notsetIsOpen(false);finallyclearsisTransitioning. The new case inLanguageSwitcher.behavior.test.tsxasserts listbox still open, spinner gone, trigger re-enabled, and uses the file's existing fake-timeradvanceTimersByTimeAsync(200)idiom to pass the 150 ms delay.
Test-only; no changelog fragment needed per changelog.d rules. The Pages changed NEUTRAL check is the preview deploy, not a failure.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
Test Improvement
Covers the two remaining reachable untested branches in the docs app at
9a1aab7:src/app/docs/[...slug]/page.tsxL207 —getPageContentfinds the slug inbuildPageMap'srouteMap, but the mapped file is on disk in neither the project content dir nor the shareddocs/contentroot. The lookup must fall through tonullsoDocPagecallsnotFound()(and never reaches the MDX compiler). No committed nav entry points at a missing file, so the newdocs-slug-page.routemap-miss.test.tsxinjects the route by wrappingbuildPageMap.src/components/LanguageSwitcher.tsxL92 —handleLanguageChangewhenrouter.replacethrows: the error is logged, the dropdown stays open, andfinallystill clears the transitioning state (spinner gone, trigger re-enabled). Added toLanguageSwitcher.behavior.test.tsx.Evidence
npx vitest run --coverageat this head: 1115 tests / 107 files, all files 99.21 st / 97.28 br / 100 fn / 99.76 ln (was 99.15 / 97.19 / 100 / 99.69).[...slug]/page.tsxlines 99.14 → 100, branches 84.88 → 87.2.eslint,prettier --checkandtsc --noEmitclean.The lines still reported uncovered (
Footer.tsx:26no-#back-to-topguard,VersionSelector.tsx:140unknown-key fallback,LanguageSwitcher.tsx:51timeout captured at mount,relay.ts:321/396) are defensive guards unreachable from the component's own render path; left as-is rather than tested through artificial mocks.No changelog fragment: test-only change (per
changelog.d/README.md).Filed by quality agent (ACMM L4/L6 — full mode)
— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88