issue-93: Add unit tests for scripts/local-install.mjs (node --test) #100
No reviewers
Labels
No labels
bug
chore
documentation
enhancement
feature
ready
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
david/pi-extensions-and-skills!100
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/issue-93/add-unit-tests-for-scripts-local-install-mjs-node"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
93: Add unit tests for scripts/local-install.mjs (node --test)
Implements 93.
Generated in 44m 38s.
Review findings
Now let me read the test file:
I have the full picture. Let me check the project gates and count the hardcoded URL occurrences:
I have the full picture now. My plan:
npmSilentFailoption tomakeShimDir/runMainAndCaptureAbort, and add a test for thenpm install failed:\nexit status 1fallback.REPO_URLfromlocal-install.mjs(as per the suggested fix, making it the single source of truth), import it in the tests, and replace all hardcoded occurrences — including alternative syntax forms (scp-like, ssh://, git://, port, schemeless) derived from it.pi remove.Applying the fixes:
All 34 replacements applied. Now let me verify remaining occurrences and run the test gate:
The only remaining occurrences are hardcoded expected-result literals (
{ host, owner, repo }), which is intentional — per testing conventions, assertions should be made against literal values rather than recomputed variables. All URL inputs now derive fromREPO_URL. Running the gate:All 57 tests pass (55 original + 2 new). Let me confirm the new tests ran and review the final diff:
Both new tests pass (#39 dedupe, #52 npm silent-fail). Final sanity check on the production-code change:
All fixes are in place and verified: 57/57 tests pass (the only applicable gate; no build/lint scripts exist at the repo root), the production change is a single additive
export, and the working tree is left uncommitted as required.Review Findings — 93: Add unit tests for scripts/local-install.mjs (node --test)
Summary
Remediated in a single pass: (1) added an
npmSilentFailshim option plus a test covering thenpm install failed:\nexit status 1exit-status fallback abort; (2) madeREPO_URLthe single source of truth by exporting it fromscripts/local-install.mjs, importing it in the test file, and replacing every hardcoded URL occurrence — including alternative-syntax forms (scp-like, ssh://, git://, port, scheme-less, embedded credentials) derived vianew URL(REPO_URL)and lookalike-extra/-backupvariants (expected parse-result literals intentionally kept as hardcoded assertions); (3) added a test asserting a duplicated URL entry in one settings file yields exactly onepi remove. Remaining: the commit-message-format finding, which its own suggested fix marks as out of scope for this MR (documentation PR). Gate re-run:npm test→ 57/57 pass (was 55; +2 new tests), 0 fail/skip.Critical
(none)
High
(none)
Medium
failureDetailexit-status fallback (pullSilentFail,piRemoveSilentFail,piInstallSilentFail), butnpm installonly has the stderr-detail path (npmFails); thenpm install failed:\nexit status Nabort message is untested. Suggested fix: add annpmSilentFailoption tomakeShimDir(bodyexit 1, no output) and a test asserting abort withnpm install failed:\nexit status 1.Low
REPO_URLconstant is only partially adopted: ~48 occurrences of the hardcoded URL remain (e.g. lines 289, 375, 648, 677, 740), so the "must match scripts/local-install.mjs" duplication the comment warns about still exists for most tests. Suggested fix: replace hardcoded occurrences withREPO_URL(or exportREPO_URLfrom local-install.mjs and import it, making a single source of truth).seen-set dedupe indedupeAndRegister(same matching source listed twice in one settings file →pi removeruns once) is untested; existing tests only cover distinct sources. Suggested fix: add a test with the same URL entry duplicated inpackagesand assert the pi log contains exactly oneremove <url>line.9557703uses message format93: <summary>, but AGENTS.md specifiesissue-<N>: <summary>for issue-driven work; all prior commits in this repo also use bare<N>:, so this is doc drift rather than a one-off. Suggested fix: no code change needed for this MR; align AGENTS.md with the established<N>:convention (or vice versa) in a documentation PR.