diff --git a/src/db/seed.ts b/src/db/seed.ts index 6620b52..6581321 100644 --- a/src/db/seed.ts +++ b/src/db/seed.ts @@ -110,8 +110,8 @@ async function main() { validTo.setDate(today.getDate() + 5); const flyerQuery = ` - INSERT INTO public.flyers (file_name, image_url, checksum, store_id, valid_from, valid_to) - VALUES ('safeway-flyer.jpg', 'https://example.com/flyer-images/safeway-flyer.jpg', 'a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0', ${storeMap.get('Safeway')}, $1, $2) + INSERT INTO public.flyers (file_name, image_url, icon_url, checksum, store_id, valid_from, valid_to) + VALUES ('safeway-flyer.jpg', 'https://example.com/flyer-images/safeway-flyer.jpg', 'https://example.com/flyer-images/icons/safeway-flyer.jpg', 'a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0', ${storeMap.get('Safeway')}, $1, $2) RETURNING flyer_id; `; const flyerRes = await client.query<{ flyer_id: number }>(flyerQuery, [ diff --git a/src/tests/integration/admin.integration.test.ts b/src/tests/integration/admin.integration.test.ts index 8541cb3..27804f8 100644 --- a/src/tests/integration/admin.integration.test.ts +++ b/src/tests/integration/admin.integration.test.ts @@ -163,8 +163,8 @@ describe('Admin API Routes Integration Tests', () => { // Before each modification test, create a fresh flyer item and a correction for it. beforeEach(async () => { const flyerRes = await getPool().query( - `INSERT INTO public.flyers (store_id, file_name, image_url, item_count, checksum) - VALUES ($1, 'admin-test.jpg', 'https://example.com/flyer-images/asdmin-test.jpg', 1, $2) RETURNING flyer_id`, + `INSERT INTO public.flyers (store_id, file_name, image_url, icon_url, item_count, checksum) + VALUES ($1, 'admin-test.jpg', 'https://example.com/flyer-images/asdmin-test.jpg', 'https://example.com/flyer-images/icons/admin-test.jpg', 1, $2) RETURNING flyer_id`, // The checksum must be a unique 64-character string to satisfy the DB constraint. // We generate a dynamic string and pad it to 64 characters. [testStoreId, `checksum-${Date.now()}-${Math.random()}`.padEnd(64, '0')], diff --git a/src/tests/integration/flyer.integration.test.ts b/src/tests/integration/flyer.integration.test.ts index ecd58ee..7faced3 100644 --- a/src/tests/integration/flyer.integration.test.ts +++ b/src/tests/integration/flyer.integration.test.ts @@ -24,8 +24,8 @@ describe('Public Flyer API Routes Integration Tests', () => { const storeId = storeRes.rows[0].store_id; const flyerRes = await getPool().query( - `INSERT INTO public.flyers (store_id, file_name, image_url, item_count, checksum) - VALUES ($1, 'integration-test.jpg', 'https://example.com/flyer-images/integration-test.jpg', 1, $2) RETURNING flyer_id`, + `INSERT INTO public.flyers (store_id, file_name, image_url, icon_url, item_count, checksum) + VALUES ($1, 'integration-test.jpg', 'https://example.com/flyer-images/integration-test.jpg', 'https://example.com/flyer-images/icons/integration-test.jpg', 1, $2) RETURNING flyer_id`, [storeId, `${Date.now().toString(16)}`.padEnd(64, '0')], ); createdFlyerId = flyerRes.rows[0].flyer_id; diff --git a/src/tests/integration/price.integration.test.ts b/src/tests/integration/price.integration.test.ts index a9136ea..0e01597 100644 --- a/src/tests/integration/price.integration.test.ts +++ b/src/tests/integration/price.integration.test.ts @@ -34,22 +34,22 @@ describe('Price History API Integration Test (/api/price-history)', () => { // 3. Create two flyers with different dates const flyerRes1 = await pool.query( - `INSERT INTO public.flyers (store_id, file_name, image_url, item_count, checksum, valid_from) - VALUES ($1, 'price-test-1.jpg', 'https://example.com/flyer-images/price-test-1.jpg', 1, $2, '2025-01-01') RETURNING flyer_id`, + `INSERT INTO public.flyers (store_id, file_name, image_url, icon_url, item_count, checksum, valid_from) + VALUES ($1, 'price-test-1.jpg', 'https://example.com/flyer-images/price-test-1.jpg', 'https://example.com/flyer-images/icons/price-test-1.jpg', 1, $2, '2025-01-01') RETURNING flyer_id`, [storeId, `${Date.now().toString(16)}1`.padEnd(64, '0')], ); flyerId1 = flyerRes1.rows[0].flyer_id; const flyerRes2 = await pool.query( - `INSERT INTO public.flyers (store_id, file_name, image_url, item_count, checksum, valid_from) - VALUES ($1, 'price-test-2.jpg', 'https://example.com/flyer-images/price-test-2.jpg', 1, $2, '2025-01-08') RETURNING flyer_id`, + `INSERT INTO public.flyers (store_id, file_name, image_url, icon_url, item_count, checksum, valid_from) + VALUES ($1, 'price-test-2.jpg', 'https://example.com/flyer-images/price-test-2.jpg', 'https://example.com/flyer-images/icons/price-test-2.jpg', 1, $2, '2025-01-08') RETURNING flyer_id`, [storeId, `${Date.now().toString(16)}2`.padEnd(64, '0')], ); flyerId2 = flyerRes2.rows[0].flyer_id; // This was a duplicate, fixed. const flyerRes3 = await pool.query( - `INSERT INTO public.flyers (store_id, file_name, image_url, item_count, checksum, valid_from) - VALUES ($1, 'price-test-3.jpg', 'https://example.com/flyer-images/price-test-3.jpg', 1, $2, '2025-01-15') RETURNING flyer_id`, + `INSERT INTO public.flyers (store_id, file_name, image_url, icon_url, item_count, checksum, valid_from) + VALUES ($1, 'price-test-3.jpg', 'https://example.com/flyer-images/price-test-3.jpg', 'https://example.com/flyer-images/icons/price-test-3.jpg', 1, $2, '2025-01-15') RETURNING flyer_id`, [storeId, `${Date.now().toString(16)}3`.padEnd(64, '0')], ); flyerId3 = flyerRes3.rows[0].flyer_id; diff --git a/src/tests/integration/public.routes.integration.test.ts b/src/tests/integration/public.routes.integration.test.ts index 7f08141..71d33f2 100644 --- a/src/tests/integration/public.routes.integration.test.ts +++ b/src/tests/integration/public.routes.integration.test.ts @@ -77,8 +77,8 @@ describe('Public API Routes Integration Tests', () => { ); testStoreId = storeRes.rows[0].store_id; const flyerRes = await pool.query( - `INSERT INTO public.flyers (store_id, file_name, image_url, item_count, checksum) - VALUES ($1, 'public-routes-test.jpg', 'https://example.com/flyer-images/public-routes-test.jpg', 1, $2) RETURNING *`, + `INSERT INTO public.flyers (store_id, file_name, image_url, icon_url, item_count, checksum) + VALUES ($1, 'public-routes-test.jpg', 'https://example.com/flyer-images/public-routes-test.jpg', 'https://example.com/flyer-images/icons/public-routes-test.jpg', 1, $2) RETURNING *`, [testStoreId, `${Date.now().toString(16)}`.padEnd(64, '0')], ); testFlyer = flyerRes.rows[0];