mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-12-04 03:07:08 +03:00
fixes
This commit is contained in:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user