Overview
Write a comprehensive integration test suite for the restaurant and food item modules using the same Vitest + Supertest + `mongodb-memory-server` pattern established in `apps/api/src/modules/auth/tests/auth.test.ts`. Tests must run without any external services — no real MongoDB, no S3.
Dependencies: Issues #180 (Restaurant module), #181 (Food item module), and #186 (Pagination/filtering) must be merged before this issue can be completed.
Test Files
```
apps/api/src/modules/restaurants/tests/restaurant.test.ts
apps/api/src/modules/food-items/tests/food-item.test.ts
```
Both files follow the same `beforeAll` / `afterEach` / `afterAll` setup as `auth.test.ts`:
```ts
let mongoServer: MongoMemoryServer;
beforeAll(async () => {
mongoServer = await MongoMemoryServer.create();
await mongoose.connect(mongoServer.getUri());
});
afterEach(async () => {
await mongoose.connection.dropDatabase();
});
afterAll(async () => {
await mongoose.disconnect();
await mongoServer.stop();
});
```
Restaurant Test Cases (`restaurant.test.ts`)
POST /api/restaurants
GET /api/restaurants
GET /api/restaurants/:id
GET /api/restaurants/me
PATCH /api/restaurants/:id
DELETE /api/restaurants/:id
Food Item Test Cases (`food-item.test.ts`)
POST /api/restaurants/:restaurantId/food-items
GET /api/restaurants/:restaurantId/food-items
GET /api/restaurants/:restaurantId/food-items/:id
PATCH /api/restaurants/:restaurantId/food-items/:id
DELETE /api/restaurants/:restaurantId/food-items/:id
Helpers
Create a `tests/helpers/` directory with shared test utilities:
```
apps/api/src/tests/helpers/
create-user.ts # Register a user and return { token, userId }
create-restaurant.ts # Create a restaurant for a user and return it
create-food-item.ts # Create a food item and return it
```
These helpers eliminate boilerplate setup in each `describe` block and make test intent clear.
Acceptance Criteria
Overview
Write a comprehensive integration test suite for the restaurant and food item modules using the same Vitest + Supertest + `mongodb-memory-server` pattern established in `apps/api/src/modules/auth/tests/auth.test.ts`. Tests must run without any external services — no real MongoDB, no S3.
Dependencies: Issues #180 (Restaurant module), #181 (Food item module), and #186 (Pagination/filtering) must be merged before this issue can be completed.
Test Files
```
apps/api/src/modules/restaurants/tests/restaurant.test.ts
apps/api/src/modules/food-items/tests/food-item.test.ts
```
Both files follow the same `beforeAll` / `afterEach` / `afterAll` setup as `auth.test.ts`:
```ts
let mongoServer: MongoMemoryServer;
beforeAll(async () => {
mongoServer = await MongoMemoryServer.create();
await mongoose.connect(mongoServer.getUri());
});
afterEach(async () => {
await mongoose.connection.dropDatabase();
});
afterAll(async () => {
await mongoose.disconnect();
await mongoServer.stop();
});
```
Restaurant Test Cases (`restaurant.test.ts`)
POST /api/restaurants
GET /api/restaurants
GET /api/restaurants/:id
GET /api/restaurants/me
PATCH /api/restaurants/:id
DELETE /api/restaurants/:id
Food Item Test Cases (`food-item.test.ts`)
POST /api/restaurants/:restaurantId/food-items
GET /api/restaurants/:restaurantId/food-items
GET /api/restaurants/:restaurantId/food-items/:id
PATCH /api/restaurants/:restaurantId/food-items/:id
DELETE /api/restaurants/:restaurantId/food-items/:id
Helpers
Create a `tests/helpers/` directory with shared test utilities:
```
apps/api/src/tests/helpers/
create-user.ts # Register a user and return { token, userId }
create-restaurant.ts # Create a restaurant for a user and return it
create-food-item.ts # Create a food item and return it
```
These helpers eliminate boilerplate setup in each `describe` block and make test intent clear.
Acceptance Criteria