fix: isolate scan tests from the developer's real ~/.polylane credentials - #24
Merged
Conversation
…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>
|
Warning Polylane could not verify the production impact of this pull request. Test-only change isolating scan tests from real credentials, plus restoring the Dependency changes
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. Polylane analysed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
test/scan.test.ts›investigateScanRisksmocksglobalThis.fetchand 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
HOMEat a temp dir before importing the source modules (switching to dynamic imports, sincesrc/config/paths.tscomputesCONFIG_DIRfromhomedir()at module load), and clean it up in anafterhook. This is the same isolation patterntest/signup.test.tsalready uses.Verification
npm test: 183/183 pass (was 182/183 with an expired local token)npm run typecheck: clean🤖 Generated with Claude Code