From 4c1ac499d6708f131c8aee060afd784e46c061ca Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 9 Sep 2025 13:44:30 -0700 Subject: [PATCH] prettier --- .../gui/chat-tests/EditToolScenarios.test.tsx | 57 ++++++++------- .../chat-tests/EditToolScenariosYolo.test.tsx | 73 +++++++++---------- .../ParallelToolCallsActions.test.tsx | 44 +++++------ .../ParallelToolCallsBasic.test.tsx | 44 +++++------ .../ParallelToolCallsStreaming.test.tsx | 44 +++++------ 5 files changed, 134 insertions(+), 128 deletions(-) diff --git a/gui/src/pages/gui/chat-tests/EditToolScenarios.test.tsx b/gui/src/pages/gui/chat-tests/EditToolScenarios.test.tsx index 656b8c261..85dbecdee 100644 --- a/gui/src/pages/gui/chat-tests/EditToolScenarios.test.tsx +++ b/gui/src/pages/gui/chat-tests/EditToolScenarios.test.tsx @@ -54,9 +54,9 @@ beforeEach(async () => { // Clear any persisted state to ensure test isolation localStorage.clear(); sessionStorage.clear(); - + // Add a small delay to ensure cleanup is complete - await new Promise(resolve => setTimeout(resolve, 50)); + await new Promise((resolve) => setTimeout(resolve, 50)); }); test( @@ -65,10 +65,10 @@ test( async () => { // Setup const { ideMessenger, store, user } = await renderWithProviders(); - + // Reset mocks to ensure clean state ideMessenger.resetMocks(); - + // Reset streaming state to prevent test interference store.dispatch(setInactive()); @@ -76,40 +76,42 @@ test( ideMessenger.responses["tools/evaluatePolicy"] = { policy: "allowedWithPermission", }; - + // Mock context/getSymbolsForFiles to prevent errors during streaming ideMessenger.responses["context/getSymbolsForFiles"] = {}; - + const messengerPostSpy = vi.spyOn(ideMessenger, "post"); const messengerRequestSpy = vi.spyOn(ideMessenger, "request"); // Instead of using addAndSelectMockLlm (which relies on events that might be failing), // directly dispatch the config update to set the selected model const currentConfig = store.getState().config.config; - store.dispatch(updateConfig({ - ...currentConfig, - selectedModelByRole: { - ...currentConfig.selectedModelByRole, - chat: { - model: "mock", - provider: "mock", - title: "Mock LLM", - underlyingProviderName: "mock", - } - }, - modelsByRole: { - ...currentConfig.modelsByRole, - chat: [ - ...(currentConfig.modelsByRole.chat || []), - { + store.dispatch( + updateConfig({ + ...currentConfig, + selectedModelByRole: { + ...currentConfig.selectedModelByRole, + chat: { model: "mock", provider: "mock", - title: "Mock LLM", + title: "Mock LLM", underlyingProviderName: "mock", - } - ] - } - })); + }, + }, + modelsByRole: { + ...currentConfig.modelsByRole, + chat: [ + ...(currentConfig.modelsByRole.chat || []), + { + model: "mock", + provider: "mock", + title: "Mock LLM", + underlyingProviderName: "mock", + }, + ], + }, + }), + ); // Send the input that will respond with an edit tool call await sendInputWithMockedResponse( @@ -210,4 +212,3 @@ test( // }); }, ); - diff --git a/gui/src/pages/gui/chat-tests/EditToolScenariosYolo.test.tsx b/gui/src/pages/gui/chat-tests/EditToolScenariosYolo.test.tsx index 4ca1e72f2..c13d46773 100644 --- a/gui/src/pages/gui/chat-tests/EditToolScenariosYolo.test.tsx +++ b/gui/src/pages/gui/chat-tests/EditToolScenariosYolo.test.tsx @@ -1,8 +1,6 @@ import { BuiltInToolNames } from "core/tools/builtIn"; import { generateToolCallButtonTestId } from "../../../components/mainInput/Lump/LumpToolbar/PendingToolCallToolbar"; -import { - triggerConfigUpdate, -} from "../../../util/test/config"; +import { triggerConfigUpdate } from "../../../util/test/config"; import { updateConfig } from "../../../redux/slices/configSlice"; import { renderWithProviders } from "../../../util/test/render"; import { Chat } from "../Chat"; @@ -53,67 +51,69 @@ beforeEach(async () => { // Clear any persisted state to ensure test isolation localStorage.clear(); sessionStorage.clear(); - + // Add a small delay to ensure cleanup is complete - await new Promise(resolve => setTimeout(resolve, 50)); + await new Promise((resolve) => setTimeout(resolve, 50)); }); test("Edit run with no policy and yolo mode", { timeout: 15000 }, async () => { // Additional cleanup before test starts localStorage.clear(); sessionStorage.clear(); - await new Promise(resolve => setTimeout(resolve, 100)); - + await new Promise((resolve) => setTimeout(resolve, 100)); + // Setup const { ideMessenger, store, user } = await renderWithProviders(); - + // Reset mocks to ensure clean state ideMessenger.resetMocks(); - - // Reset streaming state to prevent test interference + + // Reset streaming state to prevent test interference store.dispatch(setInactive()); - + // Additional delay to ensure state is fully reset - await new Promise(resolve => setTimeout(resolve, 100)); + await new Promise((resolve) => setTimeout(resolve, 100)); ideMessenger.responses["getWorkspaceDirs"] = [EDIT_WORKSPACE_DIR]; ideMessenger.responses["tools/evaluatePolicy"] = { policy: "allowedWithoutPermission", }; - + // Mock context/getSymbolsForFiles to prevent errors during streaming ideMessenger.responses["context/getSymbolsForFiles"] = {}; - + const messengerPostSpy = vi.spyOn(ideMessenger, "post"); const messengerRequestSpy = vi.spyOn(ideMessenger, "request"); // Instead of using addAndSelectMockLlm (which relies on events that might be failing), // directly dispatch the config update to set the selected model const currentConfig = store.getState().config.config; - store.dispatch(updateConfig({ - ...currentConfig, - selectedModelByRole: { - ...currentConfig.selectedModelByRole, - chat: { - model: "mock", - provider: "mock", - title: "Mock LLM", - underlyingProviderName: "mock", - } - }, - modelsByRole: { - ...currentConfig.modelsByRole, - chat: [ - ...(currentConfig.modelsByRole.chat || []), - { + store.dispatch( + updateConfig({ + ...currentConfig, + selectedModelByRole: { + ...currentConfig.selectedModelByRole, + chat: { model: "mock", provider: "mock", - title: "Mock LLM", + title: "Mock LLM", underlyingProviderName: "mock", - } - ] - } - })); + }, + }, + modelsByRole: { + ...currentConfig.modelsByRole, + chat: [ + ...(currentConfig.modelsByRole.chat || []), + { + model: "mock", + provider: "mock", + title: "Mock LLM", + underlyingProviderName: "mock", + }, + ], + }, + }), + ); // Enable automatic edit and yolo mode store.dispatch( @@ -147,7 +147,6 @@ test("Edit run with no policy and yolo mode", { timeout: 15000 }, async () => { await new Promise((resolve) => setTimeout(resolve, 1000)); }); - // Toggle the codeblock and make sure the changes show const toggleCodeblockChevron = await getElementByTestId("toggle-codeblock"); @@ -226,4 +225,4 @@ test("Edit run with no policy and yolo mode", { timeout: 15000 }, async () => { // await waitFor(() => getElementByText(POST_EDIT_RESPONSE), { // timeout: 8000, // }); -}); \ No newline at end of file +}); diff --git a/gui/src/pages/gui/chat-tests/ParallelToolCallsActions.test.tsx b/gui/src/pages/gui/chat-tests/ParallelToolCallsActions.test.tsx index f71c1b45c..fe396f7c2 100644 --- a/gui/src/pages/gui/chat-tests/ParallelToolCallsActions.test.tsx +++ b/gui/src/pages/gui/chat-tests/ParallelToolCallsActions.test.tsx @@ -51,30 +51,32 @@ describe("Parallel Tool Calls - Actions", () => { // Setup mock model with direct Redux dispatch const currentConfig = store.getState().config.config; - store.dispatch(updateConfig({ - ...currentConfig, - selectedModelByRole: { - ...currentConfig.selectedModelByRole, - chat: { - model: "mock", - provider: "mock", - title: "Mock LLM", - underlyingProviderName: "mock", - } - }, - modelsByRole: { - ...currentConfig.modelsByRole, - chat: [ - ...(currentConfig.modelsByRole.chat || []), - { + store.dispatch( + updateConfig({ + ...currentConfig, + selectedModelByRole: { + ...currentConfig.selectedModelByRole, + chat: { model: "mock", provider: "mock", title: "Mock LLM", underlyingProviderName: "mock", - } - ] - } - })); + }, + }, + modelsByRole: { + ...currentConfig.modelsByRole, + chat: [ + ...(currentConfig.modelsByRole.chat || []), + { + model: "mock", + provider: "mock", + title: "Mock LLM", + underlyingProviderName: "mock", + }, + ], + }, + }), + ); await sendInputWithMockedResponse( ideMessenger, @@ -120,4 +122,4 @@ describe("Parallel Tool Calls - Actions", () => { expect(canceledToolCalls).toHaveLength(1); expect(canceledToolCalls[0].toolCallId).toBe("tool-call-1"); }); -}); \ No newline at end of file +}); diff --git a/gui/src/pages/gui/chat-tests/ParallelToolCallsBasic.test.tsx b/gui/src/pages/gui/chat-tests/ParallelToolCallsBasic.test.tsx index 4bb88e7b4..6fe3d02cc 100644 --- a/gui/src/pages/gui/chat-tests/ParallelToolCallsBasic.test.tsx +++ b/gui/src/pages/gui/chat-tests/ParallelToolCallsBasic.test.tsx @@ -49,30 +49,32 @@ describe("Parallel Tool Calls - Basic", () => { // Setup mock model with direct Redux dispatch const currentConfig = store.getState().config.config; - store.dispatch(updateConfig({ - ...currentConfig, - selectedModelByRole: { - ...currentConfig.selectedModelByRole, - chat: { - model: "mock", - provider: "mock", - title: "Mock LLM", - underlyingProviderName: "mock", - } - }, - modelsByRole: { - ...currentConfig.modelsByRole, - chat: [ - ...(currentConfig.modelsByRole.chat || []), - { + store.dispatch( + updateConfig({ + ...currentConfig, + selectedModelByRole: { + ...currentConfig.selectedModelByRole, + chat: { model: "mock", provider: "mock", title: "Mock LLM", underlyingProviderName: "mock", - } - ] - } - })); + }, + }, + modelsByRole: { + ...currentConfig.modelsByRole, + chat: [ + ...(currentConfig.modelsByRole.chat || []), + { + model: "mock", + provider: "mock", + title: "Mock LLM", + underlyingProviderName: "mock", + }, + ], + }, + }), + ); await sendInputWithMockedResponse( ideMessenger, @@ -102,4 +104,4 @@ describe("Parallel Tool Calls - Basic", () => { expect(assistantMessage!.toolCallStates![0].toolCallId).toBe("tool-call-1"); expect(assistantMessage!.toolCallStates![1].toolCallId).toBe("tool-call-2"); }); -}); \ No newline at end of file +}); diff --git a/gui/src/pages/gui/chat-tests/ParallelToolCallsStreaming.test.tsx b/gui/src/pages/gui/chat-tests/ParallelToolCallsStreaming.test.tsx index eda9f067d..9c878b83d 100644 --- a/gui/src/pages/gui/chat-tests/ParallelToolCallsStreaming.test.tsx +++ b/gui/src/pages/gui/chat-tests/ParallelToolCallsStreaming.test.tsx @@ -17,30 +17,32 @@ describe("Parallel Tool Calls - Streaming", () => { // Setup mock model with direct Redux dispatch const currentConfig = store.getState().config.config; - store.dispatch(updateConfig({ - ...currentConfig, - selectedModelByRole: { - ...currentConfig.selectedModelByRole, - chat: { - model: "mock", - provider: "mock", - title: "Mock LLM", - underlyingProviderName: "mock", - } - }, - modelsByRole: { - ...currentConfig.modelsByRole, - chat: [ - ...(currentConfig.modelsByRole.chat || []), - { + store.dispatch( + updateConfig({ + ...currentConfig, + selectedModelByRole: { + ...currentConfig.selectedModelByRole, + chat: { model: "mock", provider: "mock", title: "Mock LLM", underlyingProviderName: "mock", - } - ] - } - })); + }, + }, + modelsByRole: { + ...currentConfig.modelsByRole, + chat: [ + ...(currentConfig.modelsByRole.chat || []), + { + model: "mock", + provider: "mock", + title: "Mock LLM", + underlyingProviderName: "mock", + }, + ], + }, + }), + ); // Simulate streaming behavior with deltas const STREAMING_RESPONSE: ChatMessage[] = [ @@ -129,4 +131,4 @@ describe("Parallel Tool Calls - Streaming", () => { expect(toolCallIds).toContain("tool-call-1"); expect(toolCallIds).toContain("tool-call-2"); }); -}); \ No newline at end of file +});