fix the dang integration tests
All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 32m44s

This commit is contained in:
2026-01-05 22:38:21 -08:00
parent 0478e176d5
commit 6b2079ef2c
16 changed files with 121 additions and 56 deletions

View File

@@ -1,7 +1,6 @@
// src/tests/integration/recipe.integration.test.ts
import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest';
import supertest from 'supertest';
import app from '../../../server';
import { createAndLoginUser } from '../utils/testHelpers';
import { cleanupDb } from '../utils/cleanup';
import type { UserProfile, Recipe, RecipeComment } from '../../types';
@@ -13,9 +12,8 @@ import { aiService } from '../../services/aiService.server';
* @vitest-environment node
*/
const request = supertest(app);
describe('Recipe API Routes Integration Tests', () => {
let request: ReturnType<typeof supertest>;
let testUser: UserProfile;
let authToken: string;
let testRecipe: Recipe;
@@ -23,6 +21,10 @@ describe('Recipe API Routes Integration Tests', () => {
const createdRecipeIds: number[] = [];
beforeAll(async () => {
vi.stubEnv('FRONTEND_URL', 'https://example.com');
const app = (await import('../../../server')).default;
request = supertest(app);
// Create a user to own the recipe and perform authenticated actions
const { user, token } = await createAndLoginUser({
email: `recipe-user-${Date.now()}@example.com`,
@@ -48,6 +50,7 @@ describe('Recipe API Routes Integration Tests', () => {
});
afterAll(async () => {
vi.unstubAllEnvs();
// Clean up all created resources
await cleanupDb({
userIds: createdUserIds,