Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc4c8e2839 | ||
| 33ee2eeac9 |
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "flyer-crawler",
|
||||
"version": "0.9.53",
|
||||
"version": "0.9.54",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "flyer-crawler",
|
||||
"version": "0.9.53",
|
||||
"version": "0.9.54",
|
||||
"dependencies": {
|
||||
"@bull-board/api": "^6.14.2",
|
||||
"@bull-board/express": "^6.14.2",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "flyer-crawler",
|
||||
"private": true,
|
||||
"version": "0.9.53",
|
||||
"version": "0.9.54",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "concurrently \"npm:start:dev\" \"vite\"",
|
||||
|
||||
@@ -11,6 +11,7 @@ import type { FlyerJobData } from '../types/job-data';
|
||||
// Mock dependencies
|
||||
vi.mock('sharp', () => {
|
||||
const mockSharpInstance = {
|
||||
resize: vi.fn().mockReturnThis(),
|
||||
jpeg: vi.fn().mockReturnThis(),
|
||||
png: vi.fn().mockReturnThis(),
|
||||
toFile: vi.fn().mockResolvedValue({}),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// src/services/flyerPersistenceService.server.test.ts
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { FlyerPersistenceService } from './flyerPersistenceService.server';
|
||||
import { withTransaction } from './db/connection.db';
|
||||
@@ -77,9 +78,9 @@ describe('FlyerPersistenceService', () => {
|
||||
|
||||
const mockLogActivity = vi.fn();
|
||||
// Mock the AdminRepository constructor to return an object with logActivity
|
||||
vi.mocked(AdminRepository).mockImplementation(() => ({
|
||||
logActivity: mockLogActivity,
|
||||
} as any));
|
||||
vi.mocked(AdminRepository).mockImplementation(function () {
|
||||
return { logActivity: mockLogActivity } as any;
|
||||
});
|
||||
|
||||
const result = await service.saveFlyer(mockFlyerData, mockItemsForDb, userId, mockLogger);
|
||||
|
||||
@@ -118,9 +119,9 @@ describe('FlyerPersistenceService', () => {
|
||||
});
|
||||
|
||||
const mockLogActivity = vi.fn();
|
||||
vi.mocked(AdminRepository).mockImplementation(() => ({
|
||||
logActivity: mockLogActivity,
|
||||
} as any));
|
||||
vi.mocked(AdminRepository).mockImplementation(function () {
|
||||
return { logActivity: mockLogActivity } as any;
|
||||
});
|
||||
|
||||
const result = await service.saveFlyer(mockFlyerData, mockItemsForDb, userId, mockLogger);
|
||||
|
||||
|
||||
@@ -321,12 +321,12 @@ describe('FlyerProcessingService', () => {
|
||||
message: 'AI model exploded',
|
||||
stages: [
|
||||
{ name: 'Preparing Inputs', status: 'completed', critical: true, detail: '1 page(s) ready for AI.' },
|
||||
{ name: 'Image Optimization', status: 'completed', critical: true },
|
||||
{ name: 'Image Optimization', status: 'completed', critical: true, detail: 'Compressing and resizing images...' },
|
||||
{ name: 'Extracting Data with AI', status: 'failed', critical: true, detail: 'AI model exploded' },
|
||||
{ name: 'Transforming AI Data', status: 'skipped', critical: true },
|
||||
{ name: 'Saving to Database', status: 'skipped', critical: true },
|
||||
],
|
||||
}); // This was a duplicate, fixed.
|
||||
});
|
||||
expect(mockCleanupQueue.add).not.toHaveBeenCalled();
|
||||
expect(logger.warn).toHaveBeenCalledWith(
|
||||
'Job failed. Temporary files will NOT be cleaned up to allow for manual inspection.',
|
||||
@@ -347,7 +347,7 @@ describe('FlyerProcessingService', () => {
|
||||
message: 'An AI quota has been exceeded. Please try again later.',
|
||||
stages: [
|
||||
{ name: 'Preparing Inputs', status: 'completed', critical: true, detail: '1 page(s) ready for AI.' },
|
||||
{ name: 'Image Optimization', status: 'completed', critical: true },
|
||||
{ name: 'Image Optimization', status: 'completed', critical: true, detail: 'Compressing and resizing images...' },
|
||||
{ name: 'Extracting Data with AI', status: 'failed', critical: true, detail: 'AI model quota exceeded' },
|
||||
{ name: 'Transforming AI Data', status: 'skipped', critical: true },
|
||||
{ name: 'Saving to Database', status: 'skipped', critical: true },
|
||||
@@ -417,7 +417,7 @@ describe('FlyerProcessingService', () => {
|
||||
rawData: {},
|
||||
stages: [
|
||||
{ name: 'Preparing Inputs', status: 'completed', critical: true, detail: '1 page(s) ready for AI.' },
|
||||
{ name: 'Image Optimization', status: 'completed', critical: true },
|
||||
{ name: 'Image Optimization', status: 'completed', critical: true, detail: 'Compressing and resizing images...' },
|
||||
{ name: 'Extracting Data with AI', status: 'failed', critical: true, detail: "The AI couldn't read the flyer's format. Please try a clearer image or a different flyer." },
|
||||
{ name: 'Transforming AI Data', status: 'skipped', critical: true },
|
||||
{ name: 'Saving to Database', status: 'skipped', critical: true },
|
||||
@@ -477,7 +477,7 @@ describe('FlyerProcessingService', () => {
|
||||
message: 'A database operation failed. Please try again later.',
|
||||
stages: [
|
||||
{ name: 'Preparing Inputs', status: 'completed', critical: true, detail: '1 page(s) ready for AI.' },
|
||||
{ name: 'Image Optimization', status: 'completed', critical: true },
|
||||
{ name: 'Image Optimization', status: 'completed', critical: true, detail: 'Compressing and resizing images...' },
|
||||
{ name: 'Extracting Data with AI', status: 'completed', critical: true, detail: 'Communicating with AI model...' },
|
||||
{ name: 'Transforming AI Data', status: 'completed', critical: true },
|
||||
{ name: 'Saving to Database', status: 'failed', critical: true, detail: 'A database operation failed. Please try again later.' },
|
||||
|
||||
Reference in New Issue
Block a user