test: remove unnecessary mocks, use real filesystem#1156
test: remove unnecessary mocks, use real filesystem#1156Hweinstock wants to merge 5 commits intoaws:mainfrom
Conversation
agentcore-cli-automation
left a comment
There was a problem hiding this comment.
Nice cleanup overall — swapping in real tmp dirs makes these tests exercise more real behavior. I have a few concerns that I think are worth addressing before merging:
- The
succeeds even when cache write failstest no longer reliably triggers a write failure (chmod on the directory doesn't prevent overwriting an existing file on Linux, is bypassed by root, and is a no-op on Windows). As written, the test passes even when the cache write silently succeeds, so it no longer validates the error-handling path. resolve-ui-dist-dir.test.tsdropped thereturns null when no candidate has index.htmlandreturns the first candidate that has index.htmltests. The new replacement for the "skips AGENT_INSPECTOR_PATH..." case only assertsresult !== tmpDir, which is a significantly weaker guarantee thantoBeNull()and will pass for unrelated reasons (e.g., if any bundled candidate is present in the test environment).
Details inline.
9190b1c to
f50a436
Compare
f50a436 to
66c3764
Compare
66c3764 to
b8ca898
Compare
b8ca898 to
d719e53
Compare
d719e53 to
50834f9
Compare
50834f9 to
5c53fb6
Compare
5c53fb6 to
611346f
Compare
611346f to
62d9307
Compare
62d9307 to
354c9c3
Compare
agentcore-cli-automation
left a comment
There was a problem hiding this comment.
Thanks for addressing the earlier feedback — the update-notifier cache-write-failure test using a file-as-directory is a solid cross-platform fix, and restoring the missing resolve-ui-dist-dir test cases is appreciated.
One remaining concern worth addressing before merging: the two it.skipIf(bundledExists) tests in resolve-ui-dist-dir.test.ts will be skipped in practice in every CI run (details inline), so they effectively provide zero coverage of the paths they claim to test. Suggesting a narrow existsSync spy as a path forward.
Otherwise the refactor looks good.
eec4585 to
022c09b
Compare
agentcore-cli-automation
left a comment
There was a problem hiding this comment.
Took a pass on the latest commit (022c09b). The two substantive concerns from prior reviews — the cache-write-failure test not reliably triggering the error path, and the missing coverage for resolveUIDistDir returning null — have both been addressed:
succeeds even when cache write failsnow pointsAGENTCORE_CONFIG_DIRat a regular file, somkdir/writeFilereliably fail cross-platform without depending on permission bits or uid.resolve-ui-dist-dir.test.tsrestores thereturns null when no candidate has index.htmlandskips AGENT_INSPECTOR_PATH when env var is set but dir lacks index.htmlcases with a narrowfs.existsSyncspy, which is consistent with the "mock only at true I/O boundaries" guidance added toreview.md.
The refactor is a clear improvement — real tmp dirs exercise actual fs behavior, and dropping the compareVersions mock means the cache-path tests now verify real version comparison end-to-end. Nothing blocking from my side; approving.
…filesystem - Replace fs/promises mock with real temp directory via GLOBAL_CONFIG_DIR - Remove compareVersions mock, let real pure function run - Refactor source to use existing GLOBAL_CONFIG_DIR (supports AGENTCORE_CONFIG_DIR env var) - Only mock fetchLatestVersion (network) and PACKAGE_VERSION (constant)
- Remove redundant CACHE_DIR alias, use tmpDir directly - Add force:true to afterAll rmSync for robustness - Wrap chmod test in try/finally to prevent leaked read-only state - Remove vacuous conditional assertion in resolve-ui-dist-dir - Switch get-trace to beforeEach/afterEach for test isolation consistency
022c09b to
86e2850
Compare
Description
Remove unnecessary mocks from 4 test files, replacing them with real filesystem operations using temp directories. This improves test reliability by verifying actual behavior rather than mock call sequences.
This change refactors a few tests to no longer mock the file system (there are many others to go), and adds to the reviewer system prompt to flag this in future PRs.
Related Issue
N/A — test quality improvement
Type of Change
Testing
How have you tested the change?
npm run test:unitandnpm run test:integnpm run typechecknpm run lintsrc/assets/, I rannpm run test:update-snapshotsand committed the updated snapshotsChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.