fix(copilot): update ChatInput and store tests for renamed copilotChatMode state

This commit is contained in:
majdyz
2026-04-15 12:39:47 +07:00
parent a462396360
commit 2f8d9cc860
2 changed files with 18 additions and 16 deletions

View File

@@ -22,7 +22,7 @@ describe("useCopilotUIStore", () => {
isNotificationsEnabled: false,
isSoundEnabled: true,
showNotificationDialog: false,
copilotMode: "extended_thinking",
copilotChatMode: "extended_thinking",
});
});
@@ -154,35 +154,35 @@ describe("useCopilotUIStore", () => {
});
});
describe("copilotMode", () => {
describe("copilotChatMode", () => {
it("defaults to extended_thinking", () => {
expect(useCopilotUIStore.getState().copilotMode).toBe(
expect(useCopilotUIStore.getState().copilotChatMode).toBe(
"extended_thinking",
);
});
it("sets mode to fast", () => {
useCopilotUIStore.getState().setCopilotMode("fast");
expect(useCopilotUIStore.getState().copilotMode).toBe("fast");
useCopilotUIStore.getState().setCopilotChatMode("fast");
expect(useCopilotUIStore.getState().copilotChatMode).toBe("fast");
});
it("sets mode back to extended_thinking", () => {
useCopilotUIStore.getState().setCopilotMode("fast");
useCopilotUIStore.getState().setCopilotMode("extended_thinking");
expect(useCopilotUIStore.getState().copilotMode).toBe(
useCopilotUIStore.getState().setCopilotChatMode("fast");
useCopilotUIStore.getState().setCopilotChatMode("extended_thinking");
expect(useCopilotUIStore.getState().copilotChatMode).toBe(
"extended_thinking",
);
});
it("does not persist mode to localStorage", () => {
useCopilotUIStore.getState().setCopilotMode("fast");
useCopilotUIStore.getState().setCopilotChatMode("fast");
expect(window.localStorage.getItem("copilot-mode")).toBeNull();
});
});
describe("clearCopilotLocalData", () => {
it("resets state and clears localStorage keys", () => {
useCopilotUIStore.getState().setCopilotMode("fast");
useCopilotUIStore.getState().setCopilotChatMode("fast");
useCopilotUIStore.getState().setNotificationsEnabled(true);
useCopilotUIStore.getState().toggleSound();
useCopilotUIStore.getState().addCompletedSession("s1");
@@ -190,7 +190,7 @@ describe("useCopilotUIStore", () => {
useCopilotUIStore.getState().clearCopilotLocalData();
const state = useCopilotUIStore.getState();
expect(state.copilotMode).toBe("extended_thinking");
expect(state.copilotChatMode).toBe("extended_thinking");
expect(state.isNotificationsEnabled).toBe(false);
expect(state.isSoundEnabled).toBe(true);
expect(state.completedSessionIDs.size).toBe(0);

View File

@@ -8,14 +8,16 @@ import { afterEach, describe, expect, it, vi } from "vitest";
import { ChatInput } from "../ChatInput";
let mockCopilotMode = "extended_thinking";
const mockSetCopilotMode = vi.fn((mode: string) => {
const mockSetCopilotChatMode = vi.fn((mode: string) => {
mockCopilotMode = mode;
});
vi.mock("@/app/(platform)/copilot/store", () => ({
useCopilotUIStore: () => ({
copilotMode: mockCopilotMode,
setCopilotMode: mockSetCopilotMode,
copilotChatMode: mockCopilotMode,
setCopilotChatMode: mockSetCopilotChatMode,
copilotLlmModel: "standard",
setCopilotLlmModel: vi.fn(),
initialPrompt: null,
setInitialPrompt: vi.fn(),
}),
@@ -141,7 +143,7 @@ describe("ChatInput mode toggle", () => {
mockCopilotMode = "extended_thinking";
render(<ChatInput onSend={mockOnSend} />);
fireEvent.click(screen.getByLabelText(/switch to fast mode/i));
expect(mockSetCopilotMode).toHaveBeenCalledWith("fast");
expect(mockSetCopilotChatMode).toHaveBeenCalledWith("fast");
});
it("toggles from fast to extended_thinking on click", () => {
@@ -149,7 +151,7 @@ describe("ChatInput mode toggle", () => {
mockCopilotMode = "fast";
render(<ChatInput onSend={mockOnSend} />);
fireEvent.click(screen.getByLabelText(/switch to extended thinking/i));
expect(mockSetCopilotMode).toHaveBeenCalledWith("extended_thinking");
expect(mockSetCopilotChatMode).toHaveBeenCalledWith("extended_thinking");
});
it("hides toggle button when streaming", () => {