1. Keep session alive with ping-pong. 2. Refreshed tests.

This commit is contained in:
AG
2025-10-16 10:48:11 +03:00
parent 6f64b1daca
commit 95684a34f7
27 changed files with 420 additions and 100 deletions

View File

@@ -47,7 +47,7 @@ describe('LLMService', () => {
expect(mockGenerateContent).toHaveBeenCalledTimes(1);
const prompt = mockGenerateContent.mock.calls[0][0];
expect(prompt).toContain(JSON.stringify(desireSets));
expect(prompt).toContain('afraidToAsk' in each desire set);
expect(prompt).toContain('If an \'afraidToAsk\' idea matches, it should be treated as a \'want\'');
expect(result).toEqual({
goTo: 'apple',

View File

@@ -3,12 +3,25 @@ import cors from 'cors';
// Mock the express request, response, and next function
const mockRequest = (origin: string | undefined) => {
return { header: (name: string) => (name === 'Origin' ? origin : undefined) } as Request;
return {
headers: {
origin: origin,
},
header: (name: string) => (name === 'Origin' ? origin : undefined)
} as Request;
};
const mockResponse = () => {
const headers: { [key: string]: string | string[] | undefined } = {};
const res: Partial<Response> = {};
res.setHeader = jest.fn().mockReturnValue(res as Response);
res.setHeader = jest.fn((name: string, value: string | string[]) => {
headers[name.toLowerCase()] = value;
return res as Response;
});
res.getHeader = jest.fn((name: string) => headers[name.toLowerCase()]);
res.removeHeader = jest.fn((name: string) => {
delete headers[name.toLowerCase()];
});
res.status = jest.fn().mockReturnValue(res as Response);
res.json = jest.fn().mockReturnValue(res as Response);
return res as Response;