more test fixin
All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 13m50s

This commit is contained in:
2026-01-02 13:43:15 -08:00
parent 26763c7183
commit 2e01ad5bc9
4 changed files with 16 additions and 20 deletions

View File

@@ -94,8 +94,8 @@ export class AIService {
// 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,
// 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_lite = ["gemma-3-4b", "gemma-3-2b", "gemma-3-1b"];
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-it", "gemma-3-2b-it", "gemma-3-1b-it"];
constructor(logger: Logger, aiClient?: IAiClient, fs?: IFileSystem) {
this.logger = logger;

View File

@@ -70,8 +70,6 @@ describe('FlyerDataTransformer', () => {
mockLogger,
);
const baseUrl = `http://localhost:${process.env.PORT || 3000}`;
// Assert
// 0. Check logging
expect(mockLogger.info).toHaveBeenCalledWith(
@@ -85,8 +83,8 @@ describe('FlyerDataTransformer', () => {
// 1. Check flyer data
expect(flyerData).toEqual({
file_name: originalFileName,
image_url: `${baseUrl}/flyer-images/flyer-page-1.jpg`,
icon_url: `${baseUrl}/flyer-images/icons/icon-flyer-page-1.webp`,
image_url: `http://localhost:3000/flyer-images/flyer-page-1.jpg`,
icon_url: `http://localhost:3000/flyer-images/icons/icon-flyer-page-1.webp`,
checksum,
store_name: 'Test Store',
valid_from: '2024-01-01',
@@ -153,8 +151,6 @@ describe('FlyerDataTransformer', () => {
mockLogger,
);
const baseUrl = `http://localhost:${process.env.PORT || 3000}`;
// Assert
// 0. Check logging
expect(mockLogger.info).toHaveBeenCalledWith(
@@ -171,8 +167,8 @@ describe('FlyerDataTransformer', () => {
expect(itemsForDb).toHaveLength(0);
expect(flyerData).toEqual({
file_name: originalFileName,
image_url: `${baseUrl}/flyer-images/another.png`,
icon_url: `${baseUrl}/flyer-images/icons/icon-another.webp`,
image_url: `http://localhost:3000/flyer-images/another.png`,
icon_url: `http://localhost:3000/flyer-images/icons/icon-another.webp`,
checksum,
store_name: 'Unknown Store (auto)', // Should use fallback
valid_from: null,

View File

@@ -23,14 +23,14 @@ export class FlyerDataTransformer {
): FlyerItemInsert {
return {
...item,
// Use logical OR to default falsy values (null, undefined, '') to a fallback.
// The trim is important for cases where the AI returns only whitespace.
item: String(item.item || '').trim() || 'Unknown Item',
// Use nullish coalescing to default only null/undefined to an empty string.
price_display: String(item.price_display ?? ''),
quantity: String(item.quantity ?? ''),
// Use logical OR to default falsy category names (null, undefined, '') to a fallback.
category_name: String(item.category_name || 'Other/Miscellaneous'),
// Use nullish coalescing and trim for robustness.
// An empty or whitespace-only name falls back to 'Unknown Item'.
item: (item.item ?? '').trim() || 'Unknown Item',
// Default null/undefined to an empty string and trim.
price_display: (item.price_display ?? '').trim(),
quantity: (item.quantity ?? '').trim(),
// An empty or whitespace-only category falls back to 'Other/Miscellaneous'.
category_name: (item.category_name ?? '').trim() || 'Other/Miscellaneous',
// Use nullish coalescing to convert null to undefined for the database.
master_item_id: item.master_item_id ?? undefined,
view_count: 0,

View File

@@ -240,7 +240,7 @@ describe('Flyer Processing Background Job Integration Test', () => {
console.error('[DEBUG] EXIF test job failed:', jobStatus.failedReason);
}
expect(jobStatus?.state).toBe('completed');
const flyerId = jobStatus?.data?.flyerId;
const flyerId = jobStatus?.returnValue?.flyerId;
expect(flyerId).toBeTypeOf('number');
createdFlyerIds.push(flyerId);
@@ -326,7 +326,7 @@ describe('Flyer Processing Background Job Integration Test', () => {
console.error('[DEBUG] PNG metadata test job failed:', jobStatus.failedReason);
}
expect(jobStatus?.state).toBe('completed');
const flyerId = jobStatus?.data?.flyerId;
const flyerId = jobStatus?.returnValue?.flyerId;
expect(flyerId).toBeTypeOf('number');
createdFlyerIds.push(flyerId);