37 lines
1.4 KiB
TypeScript
37 lines
1.4 KiB
TypeScript
import { describe, it, expect, vi } from "vitest";
|
|
import { resetWorkspaceStateOnSwitch } from "./workspace-switch";
|
|
|
|
describe("resetWorkspaceStateOnSwitch", () => {
|
|
it("clears file/chat state and forces a fresh main chat session", () => {
|
|
const deps = {
|
|
setBrowseDir: vi.fn(),
|
|
setActivePath: vi.fn(),
|
|
setContent: vi.fn(),
|
|
setChatSidebarPreview: vi.fn(),
|
|
setShowChatSidebar: vi.fn(),
|
|
setActiveSessionId: vi.fn(),
|
|
setActiveSubagentKey: vi.fn(),
|
|
resetMainChat: vi.fn(),
|
|
replaceUrlToRoot: vi.fn(),
|
|
reconnectWorkspaceWatcher: vi.fn(),
|
|
refreshSessions: vi.fn(),
|
|
refreshContext: vi.fn(),
|
|
};
|
|
|
|
resetWorkspaceStateOnSwitch(deps);
|
|
|
|
expect(deps.setBrowseDir).toHaveBeenCalledWith(null);
|
|
expect(deps.setActivePath).toHaveBeenCalledWith(null);
|
|
expect(deps.setContent).toHaveBeenCalledWith({ kind: "none" });
|
|
expect(deps.setChatSidebarPreview).toHaveBeenCalledWith(null);
|
|
expect(deps.setShowChatSidebar).toHaveBeenCalledWith(true);
|
|
expect(deps.setActiveSessionId).toHaveBeenCalledWith(null);
|
|
expect(deps.setActiveSubagentKey).toHaveBeenCalledWith(null);
|
|
expect(deps.resetMainChat).toHaveBeenCalledTimes(1);
|
|
expect(deps.replaceUrlToRoot).toHaveBeenCalledTimes(1);
|
|
expect(deps.reconnectWorkspaceWatcher).toHaveBeenCalledTimes(1);
|
|
expect(deps.refreshSessions).toHaveBeenCalledTimes(1);
|
|
expect(deps.refreshContext).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|