This commit is contained in:
Patrick Erichsen 2025-09-09 13:44:30 -07:00
parent ff2b56fff3
commit 4c1ac499d6
5 changed files with 134 additions and 128 deletions

View file

@ -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(<Chat />);
// 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(
// });
},
);

View file

@ -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(<Chat />);
// 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,
// });
});
});

View file

@ -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");
});
});
});

View file

@ -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");
});
});
});

View file

@ -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");
});
});
});