Rescues three dashboard hook test files by replacing brittle coverage with stable assertions and removing their skiplist entries. - Stub global localStorage failures directly for quick chat persistence coverage. - Remove the placeholder skipped useChatRooms pagination test. - Rework useTaskDiffStats stepVersion tests around active worktree cache behavior. - Drop the rescued dashboard hook tests from the curated skiplist. Files changed: .../__tests__/quickChatLastSessionStorage.test.ts | 23 ++++-- .../app/hooks/__tests__/useChatRooms.test.ts | 6 -- .../app/hooks/__tests__/useTaskDiffStats.test.ts | 94 ++++++++++++---------- scripts/lib/dashboard-curated-skiplist.json | 12 --- 4 files changed, 67 insertions(+), 68 deletions(-) Fusion-Task-Id: FN-6442 Fusion-Task-Lineage: f2fe4791-1216-420d-9734-3938287779da
63 lines
2.3 KiB
TypeScript
63 lines
2.3 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
import {
|
|
getPersistedLastQuickChatSessionId,
|
|
removePersistedLastQuickChatSessionId,
|
|
setPersistedLastQuickChatSessionId,
|
|
} from "../quickChatLastSessionStorage";
|
|
|
|
describe("quickChatLastSessionStorage", () => {
|
|
beforeEach(() => {
|
|
vi.unstubAllGlobals();
|
|
localStorage.clear();
|
|
vi.restoreAllMocks();
|
|
});
|
|
|
|
it("stores and retrieves the last quick chat session id per project", () => {
|
|
setPersistedLastQuickChatSessionId("proj-123", "session-123");
|
|
|
|
expect(getPersistedLastQuickChatSessionId("proj-123")).toBe("session-123");
|
|
expect(localStorage.getItem("fusion:quick-chat-last-session:proj-123")).toBe("session-123");
|
|
});
|
|
|
|
it("uses a default storage bucket when project id is missing", () => {
|
|
setPersistedLastQuickChatSessionId(undefined, "session-default");
|
|
|
|
expect(getPersistedLastQuickChatSessionId()).toBe("session-default");
|
|
expect(localStorage.getItem("fusion:quick-chat-last-session:default")).toBe("session-default");
|
|
});
|
|
|
|
it("removes persisted session ids per project", () => {
|
|
setPersistedLastQuickChatSessionId("proj-123", "session-123");
|
|
|
|
removePersistedLastQuickChatSessionId("proj-123");
|
|
|
|
expect(getPersistedLastQuickChatSessionId("proj-123")).toBeNull();
|
|
});
|
|
|
|
it("returns null when nothing is saved", () => {
|
|
expect(getPersistedLastQuickChatSessionId("proj-123")).toBeNull();
|
|
});
|
|
|
|
it("swallows localStorage failures", () => {
|
|
/*
|
|
FNXC:DashboardTesting 2026-06-14-08:46:
|
|
This rescue must prove the quick-chat persistence helpers survive an unavailable storage backend; stub the global storage object directly because jsdom's Storage prototype spy can miss the Web Storage instance and create a fake-green assertion.
|
|
*/
|
|
vi.stubGlobal("localStorage", {
|
|
setItem: vi.fn(() => {
|
|
throw new Error("quota exceeded");
|
|
}),
|
|
getItem: vi.fn(() => {
|
|
throw new Error("blocked");
|
|
}),
|
|
removeItem: vi.fn(() => {
|
|
throw new Error("blocked");
|
|
}),
|
|
});
|
|
|
|
expect(() => setPersistedLastQuickChatSessionId("proj-123", "session-123")).not.toThrow();
|
|
expect(getPersistedLastQuickChatSessionId("proj-123")).toBeNull();
|
|
expect(() => removePersistedLastQuickChatSessionId("proj-123")).not.toThrow();
|
|
});
|
|
});
|