- Change default task prefix from KB to FN across all packages
- Rename branch naming pattern from kb/{id} to fusion/{id}
- Update all test assertions and fixtures to use new prefixes
- Add changeset for the breaking change
- Resolve merge conflicts in TaskCard.test.tsx touch gesture tests
54 lines
1.9 KiB
TypeScript
54 lines
1.9 KiB
TypeScript
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
import { renderHook, waitFor } from "@testing-library/react";
|
|
import { useSessionFiles } from "../useSessionFiles";
|
|
import * as api from "../../api";
|
|
|
|
vi.mock("../../api", () => ({
|
|
fetchSessionFiles: vi.fn(),
|
|
}));
|
|
|
|
const mockFetchSessionFiles = vi.mocked(api.fetchSessionFiles);
|
|
|
|
describe("useSessionFiles", () => {
|
|
beforeEach(() => {
|
|
mockFetchSessionFiles.mockReset();
|
|
});
|
|
|
|
afterEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it("fetches session files for active tasks with a worktree", async () => {
|
|
mockFetchSessionFiles.mockResolvedValueOnce(["src/a.ts", "src/b.ts"]);
|
|
|
|
const { result } = renderHook(() => useSessionFiles("FN-123", "/repo/.worktrees/kb-123", "in-progress"));
|
|
|
|
await waitFor(() => expect(result.current.loading).toBe(false));
|
|
|
|
expect(result.current.files).toEqual(["src/a.ts", "src/b.ts"]);
|
|
expect(mockFetchSessionFiles).toHaveBeenCalledWith("FN-123");
|
|
});
|
|
|
|
it("does not fetch for tasks without worktrees or inactive columns", async () => {
|
|
const { result: noWorktree } = renderHook(() => useSessionFiles("FN-123", undefined, "in-progress"));
|
|
const { result: inactive } = renderHook(() => useSessionFiles("FN-123", "/repo/.worktrees/kb-123", "todo"));
|
|
|
|
await waitFor(() => expect(noWorktree.current.loading).toBe(false));
|
|
await waitFor(() => expect(inactive.current.loading).toBe(false));
|
|
|
|
expect(noWorktree.current.files).toEqual([]);
|
|
expect(inactive.current.files).toEqual([]);
|
|
expect(mockFetchSessionFiles).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("returns empty files on fetch failure", async () => {
|
|
mockFetchSessionFiles.mockRejectedValueOnce(new Error("boom"));
|
|
|
|
const { result } = renderHook(() => useSessionFiles("FN-123", "/repo/.worktrees/kb-123", "in-review"));
|
|
|
|
await waitFor(() => expect(result.current.loading).toBe(false));
|
|
|
|
expect(result.current.files).toEqual([]);
|
|
});
|
|
});
|