Compare commits

...

2 Commits

Author SHA1 Message Date
Gitea Actions
ab63f83f50 ci: Bump version to 0.9.58 [skip ci] 2026-01-08 05:23:21 +05:00
b546a55eaf fix the dang integration tests
All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 32m3s
2026-01-07 16:22:48 -08:00
4 changed files with 42 additions and 6 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "flyer-crawler",
"version": "0.9.57",
"version": "0.9.58",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "flyer-crawler",
"version": "0.9.57",
"version": "0.9.58",
"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.57",
"version": "0.9.58",
"type": "module",
"scripts": {
"dev": "concurrently \"npm:start:dev\" \"vite\"",

View File

@@ -70,7 +70,8 @@ export class FlyerRepository {
try {
// Fallback for tests/workers sending relative URLs to satisfy DB 'url_check' constraint
const baseUrl = process.env.FRONTEND_URL || 'https://example.com';
const rawBaseUrl = process.env.FRONTEND_URL || 'https://example.com';
const baseUrl = rawBaseUrl.endsWith('/') ? rawBaseUrl.slice(0, -1) : rawBaseUrl;
// [DEBUG] Log URL transformation for debugging test failures
if ((imageUrl && !imageUrl.startsWith('http')) || (iconUrl && !iconUrl.startsWith('http'))) {
@@ -82,10 +83,12 @@ export class FlyerRepository {
}
if (imageUrl && !imageUrl.startsWith('http')) {
imageUrl = `${baseUrl}${imageUrl.startsWith('/') ? '' : '/'}${imageUrl}`;
const cleanPath = imageUrl.startsWith('/') ? imageUrl.substring(1) : imageUrl;
imageUrl = `${baseUrl}/${cleanPath}`;
}
if (iconUrl && !iconUrl.startsWith('http')) {
iconUrl = `${baseUrl}${iconUrl.startsWith('/') ? '' : '/'}${iconUrl}`;
const cleanPath = iconUrl.startsWith('/') ? iconUrl.substring(1) : iconUrl;
iconUrl = `${baseUrl}/${cleanPath}`;
}
console.error('[DB DEBUG] Final URLs for insert:', { imageUrl, iconUrl });

View File

@@ -26,6 +26,39 @@ vi.mock('../../utils/imageProcessor', async () => {
};
});
// FIX: Mock storageService to return valid URLs (for DB) and write files to disk (for test verification)
vi.mock('../../services/storage/storageService', () => {
const fs = require('node:fs/promises');
const path = require('path');
// Match the directory used in the test helpers
const uploadDir = path.join(process.cwd(), 'flyer-images');
return {
storageService: {
upload: vi.fn().mockImplementation(async (fileData, fileName) => {
const name = fileName || (fileData && fileData.name) || (typeof fileData === 'string' ? path.basename(fileData) : `upload-${Date.now()}.jpg`);
await fs.mkdir(uploadDir, { recursive: true });
const destPath = path.join(uploadDir, name);
let content = Buffer.from('');
if (Buffer.isBuffer(fileData)) {
content = fileData as any;
} else if (typeof fileData === 'string') {
try { content = await fs.readFile(fileData); } catch (e) {}
} else if (fileData && fileData.path) {
try { content = await fs.readFile(fileData.path); } catch (e) {}
}
await fs.writeFile(destPath, content);
// Return a valid URL to satisfy the 'url_check' DB constraint
return `https://example.com/uploads/${name}`;
}),
delete: vi.fn().mockResolvedValue(undefined),
}
};
});
// FIX: Import the singleton instance directly to spy on it
import { aiService } from '../../services/aiService.server';