Redesign complete. Not much UI changes

This commit is contained in:
AG
2025-10-11 19:10:58 +03:00
parent 9bbd690f40
commit f42bac001d
20 changed files with 425 additions and 64 deletions

View File

@@ -1,10 +1,16 @@
/// <reference types="jest-fetch-mock" />
import 'jest-fetch-mock';
import { FetchMock } from 'jest-fetch-mock';
import { LLMService } from '../src/services/LLMService';
require('dotenv').config();
const fetchMock = fetch as FetchMock;
describe('LLMService Refactor', () => {
let llmService: LLMService;
beforeAll(() => {
fetchMock.enableMocks(); // Enable mocks
const apiKey = process.env.GEMINI_API_KEY;
if (!apiKey) {
throw new Error('GEMINI_API_KEY is not defined in .env file');
@@ -12,7 +18,27 @@ describe('LLMService Refactor', () => {
llmService = new LLMService(apiKey);
});
afterEach(() => {
fetchMock.resetMocks(); // Reset mocks after each test
});
it('should correctly categorize desires based on the rules', async () => {
fetchMock.mockResponseOnce(JSON.stringify({
candidates: [{
content: {
parts: [{
text: JSON.stringify({
goTo: ['Pizza'],
alsoGood: ['Pasta'],
noGoes: ['Salad', 'Tacos'],
needsDiscussion: [],
considerable: []
})
}]
}
}]
}));
const desireSets = [
{ participantId: '1', wants: ['Pizza'], accepts: ['Pasta'], noGoes: ['Salad'] },
{ participantId: '2', wants: ['Pizza'], accepts: ['Pasta'], noGoes: ['Tacos'] },
@@ -26,6 +52,16 @@ describe('LLMService Refactor', () => {
});
it('should detect inner contradictions in a desire set', async () => {
fetchMock.mockResponseOnce(JSON.stringify({
candidates: [{
content: {
parts: [{
text: 'true'
}]
}
}]
}));
const desireSet = { wants: ['Ice Cream', 'No desserts'], accepts: [], noGoes: [] };
const hasContradictions = await llmService.checkForInnerContradictions(desireSet as any);
expect(hasContradictions).toBe(true);