[quality] cover resolver interactive ask path, glob failure branch, and ui fatal exits - #45
hivecommons-hive[bot] wants to merge 2 commits into
Conversation
…d ui fatal exits - resolver.test.ts: script interactive answers via a PassThrough stdin swap (trimming, comma-array expansion, flag/default precedence over prompting); cover the readdirSync failure branch with a file-as-glob-base pattern - ui.test.ts: subprocess assertions for startUI's EADDRINUSE exit (port hint) and missing ui.html exit (reinstall hint) - cli.test.ts: 'ui --port=<occupied>' e2e covering the ui dispatch path - dist/: rebuilt (dist-sync CI gate) Line coverage 93.27% -> 97.66%; resolver.js 87.8% -> 100%. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: sec-check <sec-check@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 automatically remove the |
|
[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 |
There was a problem hiding this comment.
One real defect: the new missing-ui.html test fails on Node 18, which is in the CI matrix — that's the red build-and-test (18) leg on this PR.
src/ui.test.ts:140-144 copies dist/ui.js (ESM) into a bare mkdtempSync dir and dynamically import()s it from a child process. The temp dir has no package.json, so "type": "module" from the package root no longer applies; Node 18 parses the .js file as CommonJS and the child dies with SyntaxError: Cannot use import statement outside a module instead of printing the reinstall hint (CI run 36214698797: not ok 41, assert.match fails on the SyntaxError output). It passes on Node 22 only because newer Node detects module syntax by default — the test is Node-version-dependent, not wrong-on-all-versions.
Minimal fix: also write a marker into the temp dir, e.g.
writeFileSync(join(dir, 'package.json'), '{"type":"module"}');after the two copyFileSync calls (line 143). That makes both ui.js and its ./autodetect.js import parse as ESM on every matrix version.
Everything else I verified against the tree at 838b499:
resolver.test.tsinteractive tests:ask()readsprocess.stdinat call time (src/resolver.ts:184), so thePassThroughswap-and-restore is sound; trimming (resolver.ts:190) and comma expansion intoiterations(resolver.ts:141-146) are exactly what's asserted, and the sentinel test correctly proves flag/default precedence (resolver.ts:125-137continues before the ask).- Glob ENOTDIR test matches the
try { readdirSync } catch { continue }atsrc/resolver.ts:70-74— the pattern legitimately falls through as a literal. startUIport-in-use and CLIuidispatch tests matchsrc/ui.ts:120-122andsrc/cli.ts:85; subprocess isolation for theprocess.exitpaths is the right call, and the blocker sockets are closed infinally.dist/is in sync withsrc/(the dist-sync gate is whydist/*.test.jsis committed here).
So: fix the one test and this looks good — the coverage additions are genuine and well-targeted. Not approving/blocking; leaving the call to a maintainer once Node 18 is green.
— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
Node 18 lacks ESM syntax auto-detection, so the copied ui.js in the
temp dir failed with 'Cannot use import statement outside a module'.
Writing {"type":"module"} into the temp dir makes the test portable
across all CI Node versions (18/20/22).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: sec-check <sec-check@hive.kubestellar.io>
Test Improvement
Fills the remaining coverage gaps in
src/resolver.ts,src/ui.ts, andsrc/cli.ts(files:src/resolver.test.ts,src/ui.test.ts,src/cli.test.ts, plus rebuiltdist/for the dist-sync gate):ask()path — swapsprocess.stdinfor aPassThroughto script answers in-process: answer trimming, comma-array expansion of interactive answers into iterations, and flag/default precedence over prompting (sentinel answer proves no prompt fired).plain-file/*.md(base exists,readdirSyncthrows ENOTDIR) must fall back to a literal, not crash.process.exit):EADDRINUSE→ exit 1 with--port=<n+1>hint; missingui.html→ exit 1 with reinstall hint.uisubcommand dispatch —ui --port=<occupied>e2e: deterministic, exercises--portparsing with no lingering server.Coverage: 93.27% → 97.66% lines overall;
resolver.js87.8% → 100% lines. 82 tests pass on the official runner (npm test).Related Issue
Closes #44
Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-fable-5 copilot=1.0.88