massive fixes to stores and addresses
This commit is contained in:
@@ -9,6 +9,11 @@ import type { UserProfile } from '../../types';
|
||||
import { createAndLoginUser } from '../utils/testHelpers';
|
||||
import { cleanupDb } from '../utils/cleanup';
|
||||
import { getPool } from '../../services/db/connection.db';
|
||||
import {
|
||||
createStoreWithLocation,
|
||||
cleanupStoreLocations,
|
||||
type CreatedStoreLocation,
|
||||
} from '../utils/storeHelpers';
|
||||
|
||||
/**
|
||||
* @vitest-environment node
|
||||
@@ -61,6 +66,7 @@ describe('Receipt Processing Integration Tests (/api/receipts)', () => {
|
||||
const createdUserIds: string[] = [];
|
||||
const createdReceiptIds: number[] = [];
|
||||
const createdInventoryIds: number[] = [];
|
||||
const createdStoreLocations: CreatedStoreLocation[] = [];
|
||||
|
||||
beforeAll(async () => {
|
||||
vi.stubEnv('FRONTEND_URL', 'https://example.com');
|
||||
@@ -105,6 +111,7 @@ describe('Receipt Processing Integration Tests (/api/receipts)', () => {
|
||||
}
|
||||
|
||||
await cleanupDb({ userIds: createdUserIds });
|
||||
await cleanupStoreLocations(pool, createdStoreLocations);
|
||||
});
|
||||
|
||||
describe('POST /api/receipts - Upload Receipt', () => {
|
||||
@@ -248,13 +255,15 @@ describe('Receipt Processing Integration Tests (/api/receipts)', () => {
|
||||
const pool = getPool();
|
||||
|
||||
// First create or get a test store
|
||||
const storeResult = await pool.query(
|
||||
`INSERT INTO public.stores (name)
|
||||
VALUES ('Test Store')
|
||||
ON CONFLICT (name) DO UPDATE SET name = EXCLUDED.name
|
||||
RETURNING store_id`,
|
||||
);
|
||||
const storeId = storeResult.rows[0].store_id;
|
||||
const store = await createStoreWithLocation(pool, {
|
||||
name: `Receipt Test Store - ${Date.now()}`,
|
||||
address: '999 Receipt St',
|
||||
city: 'Toronto',
|
||||
province: 'ON',
|
||||
postalCode: 'M5V 4A4',
|
||||
});
|
||||
createdStoreLocations.push(store);
|
||||
const storeId = store.storeId;
|
||||
|
||||
const result = await pool.query(
|
||||
`INSERT INTO public.receipts (user_id, receipt_image_url, status, store_id, total_amount_cents)
|
||||
|
||||
Reference in New Issue
Block a user