Skip to content

Commit f40d0e9

Browse files
yamadashyclaude
andcommitted
test(cli): decouple local-path-precedence test from repo layout
Mock fs.access to simulate an existing path instead of relying on the real src/cli directory, so the test no longer silently changes meaning if the repository layout changes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 9960531 commit f40d0e9

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

tests/cli/cliRun.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,14 @@ describe('cliRun', () => {
278278
});
279279

280280
test('should prefer existing local path over shorthand auto-detection', async () => {
281-
// `src/cli` exists relative to the repository root and matches the owner/repo pattern
282-
await runCli(['src/cli'], process.cwd(), {});
281+
// Simulate an existing local path that also matches the owner/repo pattern.
282+
// Mocking fs.access keeps the test independent of the repository's own directory layout.
283+
vi.mocked(fs.access).mockResolvedValue(undefined);
284+
285+
await runCli(['user/repo'], process.cwd(), {});
283286

284287
expect(gitRemoteHandle.checkRemoteRepoExists).not.toHaveBeenCalled();
285-
expect(defaultAction.runDefaultAction).toHaveBeenCalledWith(['src/cli'], process.cwd(), expect.any(Object));
288+
expect(defaultAction.runDefaultAction).toHaveBeenCalledWith(['user/repo'], process.cwd(), expect.any(Object));
286289
expect(remoteAction.runRemoteAction).not.toHaveBeenCalled();
287290
});
288291

0 commit comments

Comments
 (0)