Skip to content

fix: isolate scan tests from the developer's real ~/.polylane credentials - #24

Merged
boristane merged 2 commits into
mainfrom
fix/scan-test-credential-isolation
Aug 10, 2026
Merged

fix: isolate scan tests from the developer's real ~/.polylane credentials#24
boristane merged 2 commits into
mainfrom
fix/scan-test-credential-isolation

Conversation

@boristane

Copy link
Copy Markdown
Contributor

Problem

test/scan.test.tsinvestigateScanRisks mocks globalThis.fetch and asserts exactly one call, but the request path runs real credential resolution, which reads ~/.polylane/credentials.json. On a machine with an expired/expiring stored OAuth token, the client fires a token-refresh fetch before the actual API request — two calls instead of one, so the test fails locally while passing in CI (which has no credentials file).

Fix

Test-only change: point HOME at a temp dir before importing the source modules (switching to dynamic imports, since src/config/paths.ts computes CONFIG_DIR from homedir() at module load), and clean it up in an after hook. This is the same isolation pattern test/signup.test.ts already uses.

Verification

  • npm test: 183/183 pass (was 182/183 with an expired local token)
  • npm run typecheck: clean

🤖 Generated with Claude Code

…ials

The investigateScanRisks test mocks global fetch and asserts a single
call, but credential resolution read the real credentials file — an
expired stored OAuth token triggered a refresh fetch inside the mock,
failing the test on any machine with aged credentials. Point HOME at a
temp dir before importing source modules, same pattern as signup.test.ts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@polylane

polylane Bot commented Aug 10, 2026

Copy link
Copy Markdown

Warning

Polylane could not verify the production impact of this pull request.

Test-only change isolating scan tests from real credentials, plus restoring the ws dependency that src/client/workspace-socket.ts already imports. No production code paths are altered; the ws restoration fixes a missing dependency, not a regression.

View the full analysis →

Dependency changes

Package Change Jump Release age
@types/ws added 8.18.1 16 months
ws added 8.21.1 26 days

view-investigation review-in-polylane disable-pr-reviews

Polylane could not find the cloud resources this repository manages, so this review looked at the entire cloud account. Connect this repository to its resources and the next review will focus on exactly what this code deploys to.

connect-resources

Polylane analysed 262b6e3 for production impact.

PR #23 added ws and @types/ws alongside workspace-socket.ts, but the
PR #17 merge carried an older package.json that removed them again,
breaking typecheck on main (TS2307: Cannot find module 'ws'). Restore
both entries from the pre-#17 state.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@boristane
boristane merged commit 3c57681 into main Aug 10, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant