mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-11-12 14:00:35 +00:00
* fix(frontend): make chat stream server errors actionable * fix(frontend): log chat stream server errors --------- Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
|
|
import { mockLangGraphAPI } from "./utils/mock-api";
|
|
|
|
for (const { status, body, message } of [
|
|
{
|
|
status: 502,
|
|
body: '{"detail":"upstream failed"}',
|
|
message:
|
|
"The service is temporarily unavailable (HTTP 502). Please try again.",
|
|
},
|
|
{
|
|
status: 409,
|
|
body: '{"detail":"Another run is active"}',
|
|
message: 'HTTP 409: {"detail":"Another run is active"}',
|
|
},
|
|
]) {
|
|
test(`shows the expected chat error for HTTP ${status}`, async ({ page }) => {
|
|
const streamWarnings: string[] = [];
|
|
page.on("console", (entry) => {
|
|
if (
|
|
entry.type() === "warning" &&
|
|
entry.text().startsWith("Chat stream request failed:")
|
|
) {
|
|
streamWarnings.push(entry.text());
|
|
}
|
|
});
|
|
|
|
mockLangGraphAPI(page);
|
|
await page.route(
|
|
/\/api\/langgraph\/(?:threads\/[^/]+\/)?runs\/stream$/,
|
|
(route) =>
|
|
route.fulfill({ status, contentType: "application/json", body }),
|
|
);
|
|
|
|
await page.goto("/workspace/chats/new");
|
|
const composer = page.getByRole("textbox", {
|
|
name: /how can i assist you/i,
|
|
});
|
|
await composer.fill("Send a message");
|
|
await composer.press("Enter");
|
|
|
|
await expect(page.locator("[data-sonner-toast]").last()).toHaveText(
|
|
message,
|
|
);
|
|
expect(streamWarnings).toEqual(
|
|
status === 502 ? [`Chat stream request failed: HTTP 502: ${body}`] : [],
|
|
);
|
|
});
|
|
}
|