feat(FN-4552): complete Step 2 — harden openFiles workspace guards
Fusion-Task-Id: FN-4552 Fusion-Task-Lineage: dad48f2c-25a8-4fca-8f00-16307936621c
This commit is contained in:
@@ -229,6 +229,24 @@ describe("useModalManager", () => {
|
||||
expect(result.current.fileBrowserInitialFile).toBeNull();
|
||||
});
|
||||
|
||||
it("ignores non-string workspace values in openFiles and keeps existing workspace", () => {
|
||||
const { result } = renderHook(() =>
|
||||
useModalManager({ projectId: "proj_1", planningSessions: [] }),
|
||||
);
|
||||
|
||||
act(() => {
|
||||
result.current.openFiles("FN-123", "packages/dashboard/app/App.tsx");
|
||||
});
|
||||
|
||||
act(() => {
|
||||
result.current.openFiles({ type: "click" } as unknown as string, { path: "bad" } as unknown as string);
|
||||
});
|
||||
|
||||
expect(result.current.fileBrowserWorkspace).toBe("FN-123");
|
||||
expect(result.current.fileBrowserInitialFile).toBeNull();
|
||||
expect(result.current.filesOpen).toBe(true);
|
||||
});
|
||||
|
||||
it("accepts plain Task object in openDetailWithChangesTab", () => {
|
||||
const task = createTask("FN-789");
|
||||
const { result } = renderHook(() =>
|
||||
|
||||
@@ -290,10 +290,14 @@ export function useModalManager(options: UseModalManagerOptions): ModalManager {
|
||||
}, []);
|
||||
|
||||
const openFiles = useCallback((workspace?: string, initialFile?: string | null) => {
|
||||
if (workspace) {
|
||||
if (typeof workspace === "string" && workspace) {
|
||||
setFileBrowserWorkspace(workspace);
|
||||
}
|
||||
setFileBrowserInitialFile(initialFile ?? null);
|
||||
if (typeof initialFile === "string" || initialFile === null) {
|
||||
setFileBrowserInitialFile(initialFile);
|
||||
} else {
|
||||
setFileBrowserInitialFile(null);
|
||||
}
|
||||
setFilesOpen(true);
|
||||
}, []);
|
||||
const closeFiles = useCallback(() => {
|
||||
@@ -303,7 +307,9 @@ export function useModalManager(options: UseModalManagerOptions): ModalManager {
|
||||
const openTodos = useCallback(() => setTodosOpen(true), []);
|
||||
const closeTodos = useCallback(() => setTodosOpen(false), []);
|
||||
const setFileWorkspace = useCallback((workspace: string) => {
|
||||
setFileBrowserWorkspace(workspace);
|
||||
if (typeof workspace === "string" && workspace) {
|
||||
setFileBrowserWorkspace(workspace);
|
||||
}
|
||||
}, []);
|
||||
|
||||
const openActivityLog = useCallback(() => setActivityLogOpen(true), []);
|
||||
|
||||
Reference in New Issue
Block a user