fix(dashboard): ensure file/import API calls are project-scoped in tests

Update 4 test files to pass projectId="project-1" to hooks/components
and assert it flows through to the API layer:
- useFileBrowser: fetchFileList receives (taskId, path, projectId)
- useFileEditor: fetchFileContent/saveFileContent receive projectId
- FileBrowser: deleteFile/renameFile/copyFile/moveFile receive projectId
- GitHubImportModal: apiImportGitHubIssue/Pull receive projectId

All 6653 tests pass across 242 test files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-04-12 21:40:34 -07:00
parent e5b1bb1abe
commit a10dfe5f21
4 changed files with 20 additions and 19 deletions

View File

@@ -94,7 +94,7 @@ describe("useFileBrowser", () => {
.mockRejectedValueOnce(new Error("boom"))
.mockResolvedValueOnce(response("src", ["index.ts"]));
const { result } = renderHook(() => useFileBrowser("FN-001", true));
const { result } = renderHook(() => useFileBrowser("FN-001", true, "project-1"));
await waitFor(() => {
expect(result.current.error).toBe("boom");
@@ -108,16 +108,16 @@ describe("useFileBrowser", () => {
expect(result.current.error).toBeNull();
await waitFor(() => {
expect(mockFetchFileList).toHaveBeenLastCalledWith("FN-001", "src");
expect(mockFetchFileList).toHaveBeenLastCalledWith("FN-001", "src", "project-1");
expect(result.current.entries.map((entry) => entry.name)).toEqual(["index.ts"]);
});
});
it("normalizes '.' path to undefined when calling fetchFileList", async () => {
const { result } = renderHook(() => useFileBrowser("FN-001", true));
const { result } = renderHook(() => useFileBrowser("FN-001", true, "project-1"));
await waitFor(() => {
expect(mockFetchFileList).toHaveBeenCalledWith("FN-001", undefined);
expect(mockFetchFileList).toHaveBeenCalledWith("FN-001", undefined, "project-1");
});
act(() => {
@@ -125,12 +125,12 @@ describe("useFileBrowser", () => {
});
await waitFor(() => {
expect(mockFetchFileList).toHaveBeenLastCalledWith("FN-001", undefined);
expect(mockFetchFileList).toHaveBeenLastCalledWith("FN-001", undefined, "project-1");
});
});
it("passes non-dot paths directly to fetchFileList", async () => {
const { result } = renderHook(() => useFileBrowser("FN-001", true));
const { result } = renderHook(() => useFileBrowser("FN-001", true, "project-1"));
await waitFor(() => {
expect(mockFetchFileList).toHaveBeenCalled();
@@ -141,7 +141,7 @@ describe("useFileBrowser", () => {
});
await waitFor(() => {
expect(mockFetchFileList).toHaveBeenLastCalledWith("FN-001", "subdir");
expect(mockFetchFileList).toHaveBeenLastCalledWith("FN-001", "subdir", "project-1");
});
});