fix(FN-XXX): harden windows path handling

This commit is contained in:
gsxdsm
2026-04-29 07:35:23 -07:00
parent b1d2a9ee43
commit 42c27fcc3e
17 changed files with 189 additions and 32 deletions

View File

@@ -106,6 +106,24 @@ describe("usage", () => {
expect(second).not.toBe(first);
expect(second).toHaveLength(0);
});
it("falls back to USERPROFILE when HOME is unset", async () => {
vi.stubEnv("HOME", "");
vi.stubEnv("USERPROFILE", "/profiles/test-user");
mockReadFile.mockImplementation(async () => {
return Promise.reject(new Error("File not found"));
});
await fetchAllProviderUsage();
const readPaths = mockReadFile.mock.calls.map(([filePath]) => String(filePath));
expect(readPaths).toContain("/profiles/test-user/.claude/.credentials.json");
expect(readPaths).toContain("/profiles/test-user/.config/claude/.credentials.json");
expect(readPaths).toContain("/profiles/test-user/.codex/auth.json");
expect(readPaths).toContain("/profiles/test-user/.gemini/oauth_creds.json");
expect(readPaths.some((filePath) => filePath.startsWith("/home/testuser/"))).toBe(false);
});
});
describe("fetchGitHubCopilotUsage (via fetchAllProviderUsage)", () => {