feat(ai): add AI trace tracking and admin panel
- Add AiTrace model to Prisma schema with relations to User - Implement AiTraceService with CRUD operations for AI traces - Add new admin panel for AI traces with filtering and detail views - Integrate trace persistence in receipt import flow - Add API endpoints for listing and retrieving AI traces - Update Flutter admin UI with new AI tab and navigation - Add new domain models for AI traces and details - Add migration for AiTrace table creation BREAKING CHANGE: None
This commit is contained in:
@@ -12,12 +12,13 @@ describe('ReceiptImportService parseReceipt flow', () => {
|
||||
cat(51, 'Godis', 'Glass, godis & snacks > Godis'),
|
||||
];
|
||||
|
||||
const prismaMock = {
|
||||
receiptAlias: { findMany: jest.fn() },
|
||||
product: { findMany: jest.fn() },
|
||||
unitMapping: { findMany: jest.fn() },
|
||||
user: { findUnique: jest.fn() },
|
||||
};
|
||||
const prismaMock = {
|
||||
aiTrace: { create: jest.fn() },
|
||||
receiptAlias: { findMany: jest.fn() },
|
||||
product: { findMany: jest.fn() },
|
||||
unitMapping: { findMany: jest.fn() },
|
||||
user: { findUnique: jest.fn() },
|
||||
};
|
||||
|
||||
const aiServiceMock = {
|
||||
suggestCategory: jest.fn(),
|
||||
@@ -80,14 +81,21 @@ describe('ReceiptImportService parseReceipt flow', () => {
|
||||
confidence: 'low',
|
||||
});
|
||||
|
||||
jest
|
||||
.spyOn(service as any, 'parseReceiptViaImporter')
|
||||
.mockResolvedValue([
|
||||
{ rawName: 'MIXAD VARA', quantity: 1, unit: 'st' },
|
||||
{ rawName: 'GLOBAL CHOKLAD', quantity: 1, unit: 'st' },
|
||||
{ rawName: 'SPECIALPRODUKT 1st', quantity: 1, unit: 'st' },
|
||||
{ rawName: 'helt okänd vara', quantity: 1, unit: 'st' },
|
||||
]);
|
||||
jest
|
||||
.spyOn(service as any, 'parseReceiptViaImporter')
|
||||
.mockResolvedValue({
|
||||
items: [
|
||||
{ rawName: 'MIXAD VARA', quantity: 1, unit: 'st' },
|
||||
{ rawName: 'GLOBAL CHOKLAD', quantity: 1, unit: 'st' },
|
||||
{ rawName: 'SPECIALPRODUKT 1st', quantity: 1, unit: 'st' },
|
||||
{ rawName: 'helt okänd vara', quantity: 1, unit: 'st' },
|
||||
],
|
||||
trace: {
|
||||
prompt: 'test prompt',
|
||||
rawOutput: '{"items":[]}',
|
||||
normalizedOutput: { items: [] },
|
||||
},
|
||||
});
|
||||
|
||||
const file = {
|
||||
buffer: Buffer.from('dummy'),
|
||||
|
||||
Reference in New Issue
Block a user