Repository navigation
test(platform): pin platform()'s no-platform throw and installed-scope fall-back (src/platform/index.ts:49,51) - #609
Conversation
#607 landed platform() with two arms no suite reaches: the throw when nothing installed a platform (src/platform/index.ts:51, 0 hits in both the unit and the bundle coverage runs at 8878c9d) and the fall-back from an installed scope that has no platform for the current work to the process-wide one. Each case imports src/platform fresh so the empty slot and the installed scope never leak into the platform setup.ts gives every other test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
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. Agent PRs are held at ACMM L3–L5; an Hive will keep the |
There was a problem hiding this comment.
Read the tree, not just the diff. This looks correct to me (comment only — approval is a human's call).
Verified against src/platform/index.ts at pr head b5bc038:
- The throw case is real and previously untested:
platform()isscope.get() ?? current(src/platform/index.ts:49) thenthrow new Error('no platform installed: …')(src/platform/index.ts:51), andgrep -r "no platform installed" __tests__/finds no other test reaching it —runState.test.tsonly exercises the installed-scope concurrency path. - The fall-back test exercises the right arm: the flag-based scope returns
undefinedoutsiderun(), so?? currentresolves to thesetPlatform()value (src/platform/index.ts:49), and insiderun()the scoped value wins. The threeexpects pin both sides plus restoration. vi.resetModules()before each case means bothsrc/platformand the adapter's copy of it come from the same fresh registry, soinstallPlatformScope/setPlatformact on the instance under test and nothing leaks into the platformsetup.tsinstalls for other files.actionsPlatform()(src/adapters/actions.ts:12) builds only closures, so constructing it without a GitHub context is safe here.
Test-only, one new file, disjoint from every other held PR as the body claims. PR body matches the diff.
— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
|
/kind cleanup |
Test Improvement
Adds
__tests__/platform/platformGuards.test.ts, three cases for the two arms ofplatform()(src/platform/index.ts, added by #607) that no suite reaches:throw new Error('no platform installed: …')on line 51 when nothing has installed a platform;?? currentfall-back on line 49, from an installedPlatformScopewhoseget()has no platform for the current work (an adapter'sAsyncLocalStorageoutside any run) to the process-wide value — and the throw when that fall-back is empty too.Each case imports
src/platformfresh (vi.resetModules()before and after) so the empty slot and the installed scope never touch the platformsetup.tsgives every other test; the scope used is a tiny flag-based one rather thanAsyncLocalStoragebecause the arm under test is "scope has nothing", not concurrency, whichrunState.test.tsalready pins.Why. Both coverage runs at
main@8878c9dreport the same miss — unit (local, and CI artifactcoverage-8878c9d…of run 40801080844):DA:51,0,BRDA:49,0,1,0; bundle (artifactcoverage-e2e-8878c9d…, same run):DA:51,0,BRDA:49,2,1,0. The run was still green at 99.95 % lines (2470/2471) because the floor invitest.config.mjsis 99, so a guard written today landed with no test able to notice it being removed. Whether that floor should now be 100 lines is a maintainer call recorded as a folded finding on the coverage tracker; this PR only closes the gap.Files / cluster claimed — one new file,
__tests__/platform/platformGuards.test.ts. Disjoint from every held PR: #591/#593/#597 (plugin, dispatcher, label tests), #595 (setup.ts, config type guards), #596 (bundle scenario), #598 (testUtils.ts, ordering), #599 (tsconfig.test.json), #601 (coverageIgnoreHints.test.ts), #603 (runtime.test.ts), #605 (setupQuietActionsCore.ts). Nosrc/,dist/, config or docs file is touched.Testing
npx vitest run __tests__/platform— 4 files, 20 passednpx vitest run --coverage --exclude '__tests__/bundle/**'— 106 files, 1954 passed / 75 skipped; Lines 100 % (2471/2471), branches 99.76 % (the four remaining arm misses —close.ts:37,reopen.ts:34,approve.ts:502,auth.ts:224— predate refactor: per-event RunState on the platform; scope platform() per run #607 and are not touched here)npx eslint __tests__/platform/platformGuards.test.ts— clean?? currentfall-back fromplatform()fails "falls back to the process-wide platform…"; replacing the throw withreturn found as Platformfails both throw casesFiled by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88