Skip to content

[quality] cover resolver interactive ask path, glob failure branch, and ui fatal exits - #45

Open
hivecommons-hive[bot] wants to merge 2 commits into
mainfrom
quality/test-resolver-ask-ui-exits
Open

hivecommons-hive[bot] wants to merge 2 commits into
mainfrom
quality/test-resolver-ask-ui-exits

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Fills the remaining coverage gaps in src/resolver.ts, src/ui.ts, and src/cli.ts (files: src/resolver.test.ts, src/ui.test.ts, src/cli.test.ts, plus rebuilt dist/ for the dist-sync gate):

  • resolver interactive ask() path — swaps process.stdin for a PassThrough to 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).
  • resolver glob failure branch — plain-file/*.md (base exists, readdirSync throws ENOTDIR) must fall back to a literal, not crash.
  • ui fatal exits — subprocess tests (they call process.exit): EADDRINUSE → exit 1 with --port=<n+1> hint; missing ui.html → exit 1 with reinstall hint.
  • cli ui subcommand dispatch — ui --port=<occupied> e2e: deterministic, exercises --port parsing with no lingering server.

Coverage: 93.27% → 97.66% lines overall; resolver.js 87.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

…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>
@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.

@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Sep 26, 2026
@kubestellar-prow

Copy link
Copy Markdown

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 26, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts interactive tests: ask() reads process.stdin at call time (src/resolver.ts:184), so the PassThrough swap-and-restore is sound; trimming (resolver.ts:190) and comma expansion into iterations (resolver.ts:141-146) are exactly what's asserted, and the sentinel test correctly proves flag/default precedence (resolver.ts:125-137 continues before the ask).
  • Glob ENOTDIR test matches the try { readdirSync } catch { continue } at src/resolver.ts:70-74 — the pattern legitimately falls through as a literal.
  • startUI port-in-use and CLI ui dispatch tests match src/ui.ts:120-122 and src/cli.ts:85; subprocess isolation for the process.exit paths is the right call, and the blocker sockets are closed in finally.
  • dist/ is in sync with src/ (the dist-sync gate is why dist/*.test.js is 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copilot dco-signoff: yes Indicates the PR's author has signed the DCO. hold size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] resolver interactive ask path, glob failure branch, and ui fatal exits are untested

0 participants