优化聊天框输入聚焦逻辑,增强网络错误处理
This commit is contained in:
@@ -97,4 +97,18 @@ describe("streamCopilotChat", () => {
|
||||
{ type: "error", message: "Login expired. Please sign in again.", detail: undefined },
|
||||
]);
|
||||
});
|
||||
|
||||
it("emits network error when fetch throws", async () => {
|
||||
apiFetch.mockRejectedValue(new TypeError("Failed to fetch"));
|
||||
|
||||
const events: Array<{ type: string; message?: string; detail?: string }> = [];
|
||||
await streamCopilotChat({
|
||||
message: "hi",
|
||||
onEvent: (event) => events.push(event),
|
||||
});
|
||||
|
||||
expect(events).toEqual([
|
||||
{ type: "error", message: "network request failed", detail: "Failed to fetch" },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user