Fix TS narrowing errors in Chat.test.tsx
TypeScript control flow analysis can't track reassignment inside vi.mock callbacks, causing lastSendChatArgs to narrow to never. Use non-null assertions after the explicit toBeNull() guard. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -625,16 +625,17 @@ describe("Chat localStorage persistence (Story 145)", () => {
|
|||||||
|
|
||||||
// Verify sendChat was called with ALL prior messages + the new one
|
// Verify sendChat was called with ALL prior messages + the new one
|
||||||
expect(lastSendChatArgs).not.toBeNull();
|
expect(lastSendChatArgs).not.toBeNull();
|
||||||
expect(lastSendChatArgs?.messages).toHaveLength(3);
|
const args = lastSendChatArgs!;
|
||||||
expect(lastSendChatArgs?.messages[0]).toEqual({
|
expect(args.messages).toHaveLength(3);
|
||||||
|
expect(args.messages[0]).toEqual({
|
||||||
role: "user",
|
role: "user",
|
||||||
content: "What is Rust?",
|
content: "What is Rust?",
|
||||||
});
|
});
|
||||||
expect(lastSendChatArgs?.messages[1]).toEqual({
|
expect(args.messages[1]).toEqual({
|
||||||
role: "assistant",
|
role: "assistant",
|
||||||
content: "Rust is a systems programming language.",
|
content: "Rust is a systems programming language.",
|
||||||
});
|
});
|
||||||
expect(lastSendChatArgs?.messages[2]).toEqual({
|
expect(args.messages[2]).toEqual({
|
||||||
role: "user",
|
role: "user",
|
||||||
content: "Tell me more",
|
content: "Tell me more",
|
||||||
});
|
});
|
||||||
@@ -1343,7 +1344,7 @@ describe("Bug 264: Claude Code session ID persisted across browser refresh", ()
|
|||||||
|
|
||||||
expect(lastSendChatArgs).not.toBeNull();
|
expect(lastSendChatArgs).not.toBeNull();
|
||||||
expect(
|
expect(
|
||||||
(lastSendChatArgs?.config as Record<string, unknown>).session_id,
|
(lastSendChatArgs!.config as Record<string, unknown>).session_id,
|
||||||
).toBe("persisted-session-xyz");
|
).toBe("persisted-session-xyz");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user