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

It resets through resetDatabase instead of the SQLite snapshot mock, so it
runs in the Postgres lane as well.
This commit is contained in:
Maurice
2026-11-17 15:24:54 +01:00
parent 6010694c08
commit 33f777bcf8
3 changed files with 4 additions and 12 deletions
-1
View File
@@ -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,
+4 -10
View File
@@ -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', () => {
@@ -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",