integration tests fixes
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 4m36s

This commit is contained in:
2025-12-06 20:34:40 -08:00
parent 1d61d29c06
commit 35d3f9d2e7

View File

@@ -7,6 +7,15 @@ import { AIService } from './aiService.server';
// Explicitly unmock the service under test to ensure we import the real implementation.
vi.unmock('./aiService.server');
// Mock sharp, as it's a direct dependency of the service.
const mockToBuffer = vi.fn();
const mockExtract = vi.fn(() => ({ toBuffer: mockToBuffer }));
const mockSharp = vi.fn(() => ({ extract: mockExtract }));
vi.mock('sharp', () => ({
__esModule: true,
default: mockSharp,
}));
describe('AI Service (Server)', () => {
// Create mock dependencies that will be injected into the service
const mockAiClient = { generateContent: vi.fn() };
@@ -92,15 +101,6 @@ describe('AI Service (Server)', () => {
describe('extractTextFromImageArea', () => {
it('should call sharp to crop the image and call the AI with the correct prompt', async () => {
// Mock sharp for this specific test, as it's a direct dependency of the method.
const mockToBuffer = vi.fn();
const mockExtract = vi.fn(() => ({ toBuffer: mockToBuffer }));
const mockSharp = vi.fn(() => ({ extract: mockExtract }));
vi.mock('sharp', () => ({
__esModule: true,
default: mockSharp,
}));
const imagePath = 'path/to/image.jpg';
const cropArea = { x: 10, y: 20, width: 100, height: 50 };
const extractionType = 'store_name';