Compare commits

...

2 Commits

Author SHA1 Message Date
Gitea Actions
622c919733 ci: Bump version to 0.9.52 [skip ci] 2026-01-07 08:26:14 +05:00
c7f6b6369a fix the dang integration tests
All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 30m27s
2026-01-06 19:25:25 -08:00
4 changed files with 28 additions and 4 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "flyer-crawler",
"version": "0.9.51",
"version": "0.9.52",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "flyer-crawler",
"version": "0.9.51",
"version": "0.9.52",
"dependencies": {
"@bull-board/api": "^6.14.2",
"@bull-board/express": "^6.14.2",

View File

@@ -1,7 +1,7 @@
{
"name": "flyer-crawler",
"private": true,
"version": "0.9.51",
"version": "0.9.52",
"type": "module",
"scripts": {
"dev": "concurrently \"npm:start:dev\" \"vite\"",

View File

@@ -543,6 +543,20 @@ export class AIService {
logger.info(
`[extractCoreDataFromFlyerImage] Entering method with ${imagePaths.length} image(s).`,
);
// [TEST HOOK] Simulate an AI failure if the filename contains specific text.
// This allows integration tests to verify error handling.
if (imagePaths.some((f) => f.path.includes('ai-fail-test'))) {
logger.warn('[TEST HOOK] Simulating AI failure for test file.');
throw new Error('AI model failed to extract data.');
}
// [TEST HOOK] Simulate a specific failure for the cleanup test
if (imagePaths.some((f) => f.path.includes('cleanup-fail-test'))) {
logger.warn('[TEST HOOK] Simulating AI failure for cleanup test.');
throw new Error('Simulated AI failure for cleanup test.');
}
const prompt = this._buildFlyerExtractionPrompt(masterItems, submitterIp, userProfileAddress);
const imageParts = await Promise.all(

View File

@@ -64,7 +64,17 @@ export class FlyerRepository {
*/
async insertFlyer(flyerData: FlyerDbInsert, logger: Logger): Promise<Flyer> {
console.error('[DEBUG] FlyerRepository.insertFlyer called with:', JSON.stringify(flyerData, null, 2));
// [TEST HOOK] Simulate a database failure if the filename contains specific text.
// This allows integration tests to verify error handling without mocking the entire DB connection.
if (flyerData.file_name.includes('db-fail-test')) {
logger.warn('[TEST HOOK] Simulating DB transaction failure for test file.');
throw new Error('DB transaction failed for test.');
}
try {
// Sanitize icon_url: Ensure empty strings become NULL to avoid regex constraint violations
const iconUrl = flyerData.icon_url && flyerData.icon_url.trim() !== '' ? flyerData.icon_url : null;
const query = `
INSERT INTO flyers (
file_name, image_url, icon_url, checksum, store_id, valid_from, valid_to, store_address,
@@ -76,7 +86,7 @@ export class FlyerRepository {
const values = [
flyerData.file_name, // $1
flyerData.image_url, // $2
flyerData.icon_url, // $3
iconUrl, // $3
flyerData.checksum, // $4
flyerData.store_id, // $5
flyerData.valid_from, // $6