Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

test(web): cover bound draft retry and successive sends

Bingxi Zhao (Frank)4fa8a7dfec55
diff --git a/web/tests/chat-failed-submission-recovery.spec.tsx b/web/tests/chat-failed-submission-recovery.spec.tsx
index 03a4294c8..114b27711 100644
--- a/web/tests/chat-failed-submission-recovery.spec.tsx
+++ b/web/tests/chat-failed-submission-recovery.spec.tsx
@@ -433,6 +433,11 @@ it("restores a failed first message in a draft and can retry after reload", asyn
session_id: null,
});
await act(async () => {
+ fixture.emit?.({
+ type: "session", source: "chat", stage: "", content: "",
+ turn_id: "draft-retry", seq: 0, timestamp: Date.now() / 1000,
+ metadata: { session_id: "new-session", turn_id: "draft-retry" },
+ });
fixture.emit?.({
type: "done", source: "chat", stage: "responding", content: "",
turn_id: "draft-retry", seq: 1, timestamp: Date.now() / 1000,
@@ -491,6 +496,33 @@ it("keeps both unsent messages when a second direct send fails", async () => {
{ role: "user", content: "Hello offline", failed: true },
{ role: "user", content: "Second offline", failed: true },
]);
+ expect(screen.getByTestId("lastTurnFailed").textContent).toBe("true");
+ } finally {
+ vi.useRealTimers();
+ }
+});
+
+it("a later successful send clears only its own record", async () => {
+ vi.useFakeTimers();
+ try {
+ fixture.session = completedServerSession();
+ render(<ChatStateAdapterProvider><Harness /></ChatStateAdapterProvider>);
+ await act(async () => { fireEvent.click(screen.getByText("Load")); });
+ fireEvent.click(screen.getByText("Send"));
+ await act(async () => { await vi.advanceTimersByTimeAsync(2_400); });
+ fixture.connected = true;
+ fireEvent.click(screen.getByText("Send another"));
+ expect(readFailedSubmissions("s1")).toHaveLength(2);
+ await act(async () => {
+ fixture.emit?.({
+ type: "done", source: "chat", stage: "responding", content: "",
+ turn_id: "second-turn", seq: 2, timestamp: Date.now() / 1000,
+ metadata: { status: "completed", user_message_id: 3, assistant_message_id: 4 },
+ });
+ });
+ expect(readFailedSubmissions("s1").map((record) => record.content)).toEqual([
+ "Hello offline",
+ ]);
} finally {
vi.useRealTimers();
}