This commit is contained in:
Nicolas Mowen
2026-12-03 07:51:43 -07:00
parent a74b1e9f55
commit 0143b2d831
2 changed files with 84 additions and 4 deletions
+63
View File
@@ -411,6 +411,69 @@ test.describe("Chat — stop @medium", () => {
});
});
test.describe("Chat — new chat @medium", () => {
test("New chat during a tool-call turn stays cleared", async ({
frigateApp,
}) => {
const toolTurn = [
{ role: "system", content: "sys" },
{ role: "user", content: "find people" },
{
role: "assistant",
content: null,
tool_calls: [
{
id: "call_1",
type: "function",
function: {
name: "search_objects",
arguments: '{"label":"person"}',
},
},
],
},
{ role: "tool", tool_call_id: "call_1", content: "[]" },
];
// The mocked stream ignores the abort signal, so its remaining chunks
// and onDone still arrive after New chat: the stale request must not
// write them into the cleared chat.
await installChatStreamOverride(
frigateApp,
[
{ type: "messages", messages: toolTurn },
{ type: "content", delta: "Still answering" },
{
type: "messages",
messages: [
...toolTurn,
{ role: "assistant", content: "Still answering" },
],
},
{ type: "done" },
],
{ chunkDelayMs: 400 },
);
await frigateApp.goto("/chat");
const input = frigateApp.page.getByPlaceholder(/ask/i);
await expect(input).toBeVisible({ timeout: 10_000 });
await input.fill("find people");
await input.press("Enter");
await expect(frigateApp.page.getByText(/search objects/i)).toBeVisible({
timeout: 10_000,
});
await frigateApp.page.getByRole("button", { name: "New chat" }).click();
// Outlast the remaining chunks, then confirm nothing came back.
await frigateApp.page.waitForTimeout(1_500);
await expect(
frigateApp.page.getByRole("heading", { level: 1 }),
).toBeVisible();
await expect(frigateApp.page.getByText(/search objects/i)).toHaveCount(0);
await expect(frigateApp.page.getByText("find people")).toHaveCount(0);
});
});
test.describe("Chat — error @medium", () => {
test("non-OK response renders an error banner", async ({ frigateApp }) => {
await installChatStreamOverride(frigateApp, [], { status: 500 });