mirror of
https://github.com/zadam/trilium.git
synced 2025-11-21 16:14:23 +01:00
Complete vi.waitFor() migration for all async streaming tests
Replaced all remaining setTimeout calls with vi.waitFor() for consistency and reliability. Co-authored-by: eliandoran <21236836+eliandoran@users.noreply.github.com>
This commit is contained in:
parent
730e2da932
commit
993d53ed97
@ -382,12 +382,19 @@ describe("LLM API Tests", () => {
|
|||||||
message: "Streaming initiated successfully"
|
message: "Streaming initiated successfully"
|
||||||
});
|
});
|
||||||
|
|
||||||
// Wait for async streaming operations to complete
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 100));
|
|
||||||
|
|
||||||
// Import ws service to access mock
|
// Import ws service to access mock
|
||||||
const ws = (await import("../../services/ws.js")).default;
|
const ws = (await import("../../services/ws.js")).default;
|
||||||
|
|
||||||
|
// Wait for async streaming operations to complete
|
||||||
|
await vi.waitFor(() => {
|
||||||
|
expect(ws.sendMessageToAllClients).toHaveBeenCalledWith({
|
||||||
|
type: 'llm-stream',
|
||||||
|
chatNoteId: testChatId,
|
||||||
|
content: ' world!',
|
||||||
|
done: true
|
||||||
|
});
|
||||||
|
}, { timeout: 1000, interval: 50 });
|
||||||
|
|
||||||
// Verify WebSocket messages were sent
|
// Verify WebSocket messages were sent
|
||||||
expect(ws.sendMessageToAllClients).toHaveBeenCalledWith({
|
expect(ws.sendMessageToAllClients).toHaveBeenCalledWith({
|
||||||
type: 'llm-stream',
|
type: 'llm-stream',
|
||||||
@ -539,12 +546,19 @@ describe("LLM API Tests", () => {
|
|||||||
|
|
||||||
expect(response.status).toBe(200);
|
expect(response.status).toBe(200);
|
||||||
|
|
||||||
// Wait for async streaming operations to complete
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 100));
|
|
||||||
|
|
||||||
// Import ws service to access mock
|
// Import ws service to access mock
|
||||||
const ws = (await import("../../services/ws.js")).default;
|
const ws = (await import("../../services/ws.js")).default;
|
||||||
|
|
||||||
|
// Wait for async streaming operations to complete
|
||||||
|
await vi.waitFor(() => {
|
||||||
|
expect(ws.sendMessageToAllClients).toHaveBeenCalledWith({
|
||||||
|
type: 'llm-stream',
|
||||||
|
chatNoteId: testChatId,
|
||||||
|
thinking: 'Formulating response...',
|
||||||
|
done: false
|
||||||
|
});
|
||||||
|
}, { timeout: 1000, interval: 50 });
|
||||||
|
|
||||||
// Verify thinking messages
|
// Verify thinking messages
|
||||||
expect(ws.sendMessageToAllClients).toHaveBeenCalledWith({
|
expect(ws.sendMessageToAllClients).toHaveBeenCalledWith({
|
||||||
type: 'llm-stream',
|
type: 'llm-stream',
|
||||||
@ -589,12 +603,26 @@ describe("LLM API Tests", () => {
|
|||||||
|
|
||||||
expect(response.status).toBe(200);
|
expect(response.status).toBe(200);
|
||||||
|
|
||||||
// Wait for async streaming operations to complete
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 100));
|
|
||||||
|
|
||||||
// Import ws service to access mock
|
// Import ws service to access mock
|
||||||
const ws = (await import("../../services/ws.js")).default;
|
const ws = (await import("../../services/ws.js")).default;
|
||||||
|
|
||||||
|
// Wait for async streaming operations to complete
|
||||||
|
await vi.waitFor(() => {
|
||||||
|
expect(ws.sendMessageToAllClients).toHaveBeenCalledWith({
|
||||||
|
type: 'llm-stream',
|
||||||
|
chatNoteId: testChatId,
|
||||||
|
toolExecution: {
|
||||||
|
tool: 'calculator',
|
||||||
|
args: { expression: '2 + 2' },
|
||||||
|
result: '4',
|
||||||
|
toolCallId: 'call_123',
|
||||||
|
action: 'execute',
|
||||||
|
error: undefined
|
||||||
|
},
|
||||||
|
done: false
|
||||||
|
});
|
||||||
|
}, { timeout: 1000, interval: 50 });
|
||||||
|
|
||||||
// Verify tool execution message
|
// Verify tool execution message
|
||||||
expect(ws.sendMessageToAllClients).toHaveBeenCalledWith({
|
expect(ws.sendMessageToAllClients).toHaveBeenCalledWith({
|
||||||
type: 'llm-stream',
|
type: 'llm-stream',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user