more test fixin
All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 13m50s
All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 13m50s
This commit is contained in:
@@ -94,8 +94,8 @@ export class AIService {
|
|||||||
// The fallback list is ordered by preference (speed/cost vs. power).
|
// The fallback list is ordered by preference (speed/cost vs. power).
|
||||||
// We try the fastest models first, then the more powerful 'pro' model as a high-quality fallback,
|
// We try the fastest models first, then the more powerful 'pro' model as a high-quality fallback,
|
||||||
// and finally the 'lite' model as a last resort.
|
// and finally the 'lite' model as a last resort.
|
||||||
private readonly models = [ 'gemini-3-flash-preview', 'gemini-2.5-flash', 'gemini-2.5-flash-lite', 'gemma-3-27b', 'gemma-3-12b'];
|
private readonly models = [ 'gemini-3-flash-preview','gemini-2.5-pro', 'gemini-2.5-flash', 'gemini-2.5-flash-lite','gemini-2.0-flash-001','gemini-2.0-flash','gemini-2.0-flash-exp','gemini-2.0-flash-lite-001','gemini-2.0-flash-lite', 'gemma-3-27b-it', 'gemma-3-12b-it'];
|
||||||
private readonly models_lite = ["gemma-3-4b", "gemma-3-2b", "gemma-3-1b"];
|
private readonly models_lite = ["gemma-3-4b-it", "gemma-3-2b-it", "gemma-3-1b-it"];
|
||||||
|
|
||||||
constructor(logger: Logger, aiClient?: IAiClient, fs?: IFileSystem) {
|
constructor(logger: Logger, aiClient?: IAiClient, fs?: IFileSystem) {
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
|
|||||||
@@ -70,8 +70,6 @@ describe('FlyerDataTransformer', () => {
|
|||||||
mockLogger,
|
mockLogger,
|
||||||
);
|
);
|
||||||
|
|
||||||
const baseUrl = `http://localhost:${process.env.PORT || 3000}`;
|
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
// 0. Check logging
|
// 0. Check logging
|
||||||
expect(mockLogger.info).toHaveBeenCalledWith(
|
expect(mockLogger.info).toHaveBeenCalledWith(
|
||||||
@@ -85,8 +83,8 @@ describe('FlyerDataTransformer', () => {
|
|||||||
// 1. Check flyer data
|
// 1. Check flyer data
|
||||||
expect(flyerData).toEqual({
|
expect(flyerData).toEqual({
|
||||||
file_name: originalFileName,
|
file_name: originalFileName,
|
||||||
image_url: `${baseUrl}/flyer-images/flyer-page-1.jpg`,
|
image_url: `http://localhost:3000/flyer-images/flyer-page-1.jpg`,
|
||||||
icon_url: `${baseUrl}/flyer-images/icons/icon-flyer-page-1.webp`,
|
icon_url: `http://localhost:3000/flyer-images/icons/icon-flyer-page-1.webp`,
|
||||||
checksum,
|
checksum,
|
||||||
store_name: 'Test Store',
|
store_name: 'Test Store',
|
||||||
valid_from: '2024-01-01',
|
valid_from: '2024-01-01',
|
||||||
@@ -153,8 +151,6 @@ describe('FlyerDataTransformer', () => {
|
|||||||
mockLogger,
|
mockLogger,
|
||||||
);
|
);
|
||||||
|
|
||||||
const baseUrl = `http://localhost:${process.env.PORT || 3000}`;
|
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
// 0. Check logging
|
// 0. Check logging
|
||||||
expect(mockLogger.info).toHaveBeenCalledWith(
|
expect(mockLogger.info).toHaveBeenCalledWith(
|
||||||
@@ -171,8 +167,8 @@ describe('FlyerDataTransformer', () => {
|
|||||||
expect(itemsForDb).toHaveLength(0);
|
expect(itemsForDb).toHaveLength(0);
|
||||||
expect(flyerData).toEqual({
|
expect(flyerData).toEqual({
|
||||||
file_name: originalFileName,
|
file_name: originalFileName,
|
||||||
image_url: `${baseUrl}/flyer-images/another.png`,
|
image_url: `http://localhost:3000/flyer-images/another.png`,
|
||||||
icon_url: `${baseUrl}/flyer-images/icons/icon-another.webp`,
|
icon_url: `http://localhost:3000/flyer-images/icons/icon-another.webp`,
|
||||||
checksum,
|
checksum,
|
||||||
store_name: 'Unknown Store (auto)', // Should use fallback
|
store_name: 'Unknown Store (auto)', // Should use fallback
|
||||||
valid_from: null,
|
valid_from: null,
|
||||||
|
|||||||
@@ -23,14 +23,14 @@ export class FlyerDataTransformer {
|
|||||||
): FlyerItemInsert {
|
): FlyerItemInsert {
|
||||||
return {
|
return {
|
||||||
...item,
|
...item,
|
||||||
// Use logical OR to default falsy values (null, undefined, '') to a fallback.
|
// Use nullish coalescing and trim for robustness.
|
||||||
// The trim is important for cases where the AI returns only whitespace.
|
// An empty or whitespace-only name falls back to 'Unknown Item'.
|
||||||
item: String(item.item || '').trim() || 'Unknown Item',
|
item: (item.item ?? '').trim() || 'Unknown Item',
|
||||||
// Use nullish coalescing to default only null/undefined to an empty string.
|
// Default null/undefined to an empty string and trim.
|
||||||
price_display: String(item.price_display ?? ''),
|
price_display: (item.price_display ?? '').trim(),
|
||||||
quantity: String(item.quantity ?? ''),
|
quantity: (item.quantity ?? '').trim(),
|
||||||
// Use logical OR to default falsy category names (null, undefined, '') to a fallback.
|
// An empty or whitespace-only category falls back to 'Other/Miscellaneous'.
|
||||||
category_name: String(item.category_name || 'Other/Miscellaneous'),
|
category_name: (item.category_name ?? '').trim() || 'Other/Miscellaneous',
|
||||||
// Use nullish coalescing to convert null to undefined for the database.
|
// Use nullish coalescing to convert null to undefined for the database.
|
||||||
master_item_id: item.master_item_id ?? undefined,
|
master_item_id: item.master_item_id ?? undefined,
|
||||||
view_count: 0,
|
view_count: 0,
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ describe('Flyer Processing Background Job Integration Test', () => {
|
|||||||
console.error('[DEBUG] EXIF test job failed:', jobStatus.failedReason);
|
console.error('[DEBUG] EXIF test job failed:', jobStatus.failedReason);
|
||||||
}
|
}
|
||||||
expect(jobStatus?.state).toBe('completed');
|
expect(jobStatus?.state).toBe('completed');
|
||||||
const flyerId = jobStatus?.data?.flyerId;
|
const flyerId = jobStatus?.returnValue?.flyerId;
|
||||||
expect(flyerId).toBeTypeOf('number');
|
expect(flyerId).toBeTypeOf('number');
|
||||||
createdFlyerIds.push(flyerId);
|
createdFlyerIds.push(flyerId);
|
||||||
|
|
||||||
@@ -326,7 +326,7 @@ describe('Flyer Processing Background Job Integration Test', () => {
|
|||||||
console.error('[DEBUG] PNG metadata test job failed:', jobStatus.failedReason);
|
console.error('[DEBUG] PNG metadata test job failed:', jobStatus.failedReason);
|
||||||
}
|
}
|
||||||
expect(jobStatus?.state).toBe('completed');
|
expect(jobStatus?.state).toBe('completed');
|
||||||
const flyerId = jobStatus?.data?.flyerId;
|
const flyerId = jobStatus?.returnValue?.flyerId;
|
||||||
expect(flyerId).toBeTypeOf('number');
|
expect(flyerId).toBeTypeOf('number');
|
||||||
createdFlyerIds.push(flyerId);
|
createdFlyerIds.push(flyerId);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user