Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

test(categories): run the categories suite on the real database module

Maurice863ff62b6c20
diff --git a/server/scripts/test-mocks-baseline.json b/server/scripts/test-mocks-baseline.json
index 14f790d16..4c91bf3f7 100644
--- a/server/scripts/test-mocks-baseline.json
+++ b/server/scripts/test-mocks-baseline.json
@@ -66,7 +66,6 @@
"tests/integration/boot-sweeps-request-context.test.ts": 1,
"tests/integration/bootstrap.test.ts": 1,
"tests/integration/budget.test.ts": 1,
- "tests/integration/categories.test.ts": 1,
"tests/integration/collab.test.ts": 1,
"tests/integration/collections.test.ts": 1,
"tests/integration/dayNotes.test.ts": 1,
diff --git a/server/tests/integration/categories.test.ts b/server/tests/integration/categories.test.ts
index 18cc1cc2c..3cfe4bd7d 100644
--- a/server/tests/integration/categories.test.ts
+++ b/server/tests/integration/categories.test.ts
@@ -3,24 +3,19 @@
* Covers GET/POST/PUT/DELETE /api/categories.
*/
import { buildApp } from '../../src/bootstrap';
-import { db as testDb } from '../../src/db/database';
import { Categories } from '../../src/db/entities/Categories.entity';
import { authCookie } from '../helpers/auth';
import type { FactoryOrm } from '../helpers/factories/context';
import { findRow } from '../helpers/factories/rows';
import { makeUser, makeAdmin } from '../helpers/factories/users';
-import { resetTestDb, resetRateLimits } from '../helpers/test-db';
+import { resetDatabase } from '../helpers/reset-database';
+import { resetRateLimits } from '../helpers/test-db';
import { MikroORM } from '@mikro-orm/core';
import type { INestApplication } from '@nestjs/common';
import type { Application } from 'express';
import request from 'supertest';
-import { describe, it, expect, vi, beforeAll, beforeEach, afterAll } from 'vitest';
-
-vi.mock('../../src/db/database', async () => {
- const { createSnapshotTestDb, buildDbMock } = await import('../helpers/db-mock');
- return buildDbMock(createSnapshotTestDb());
-});
+import { describe, it, expect, beforeAll, beforeEach, afterAll } from 'vitest';
let nestApp: INestApplication;
let app: Application;
@@ -41,13 +36,12 @@ async function someCategoryId(): Promise<number> {
}
beforeEach(async () => {
- resetTestDb(testDb);
+ await resetDatabase(orm);
await resetRateLimits(nestApp);
});
afterAll(async () => {
await nestApp.close();
- testDb.close();
});
describe('Categories', () => {
diff --git a/server/tests/postgres/snapshot-suites-baseline.json b/server/tests/postgres/snapshot-suites-baseline.json
index b046ecf56..28031b2b5 100644
--- a/server/tests/postgres/snapshot-suites-baseline.json
+++ b/server/tests/postgres/snapshot-suites-baseline.json
@@ -13,7 +13,6 @@
"tests/integration/boot-sweeps-request-context.test.ts",
"tests/integration/bootstrap.test.ts",
"tests/integration/budget.test.ts",
- "tests/integration/categories.test.ts",
"tests/integration/collab.test.ts",
"tests/integration/collections.test.ts",
"tests/integration/dayNotes.test.ts",