mirror of
https://github.com/zadam/trilium.git
synced 2025-10-19 22:58:52 +02:00
chore(llm): try to fix flaky test
This commit is contained in:
parent
3a3cb0c68d
commit
8ac0425ca5
@ -3,7 +3,7 @@ import { beforeAll, describe, expect, it, vi, beforeEach, afterEach } from "vite
|
||||
import supertest from "supertest";
|
||||
import config from "../../services/config.js";
|
||||
import { refreshAuth } from "../../services/auth.js";
|
||||
import type { WebSocket } from 'ws';
|
||||
import { sleepFor } from "@triliumnext/commons";
|
||||
|
||||
// Mock the CSRF protection middleware to allow tests to pass
|
||||
vi.mock("../csrf_protection.js", () => ({
|
||||
@ -499,6 +499,7 @@ describe("LLM API Tests", () => {
|
||||
const ws = (await import("../../services/ws.js")).default;
|
||||
|
||||
// Verify thinking message was sent
|
||||
await sleepFor(1_000);
|
||||
expect(ws.sendMessageToAllClients).toHaveBeenCalledWith({
|
||||
type: 'llm-stream',
|
||||
chatNoteId: testChatId,
|
||||
|
@ -54,3 +54,11 @@ export function trimIndentation(strings: TemplateStringsArray, ...values: any[])
|
||||
}
|
||||
return output.join("\n");
|
||||
}
|
||||
|
||||
export function flushPromises() {
|
||||
return new Promise(setImmediate);
|
||||
}
|
||||
|
||||
export function sleepFor(duration: number) {
|
||||
return new Promise(resolve => setTimeout(resolve, duration));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user