mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 11:06:06 +00:00
test(db): run the session revocation, api docs, app config and help suites on the real database module
They boot the app without the SQLite snapshot mock, so they run in the Postgres lane as well. sessionRowsOf reads a user's session rows through a booted app's ORM, next to sessionRows for the suites that still hand in a better-sqlite3 handle.
This commit is contained in:
@@ -5,18 +5,13 @@
|
||||
* Boots the real buildApp() like bootstrap.test.ts.
|
||||
*/
|
||||
import { buildApp } from '../../src/bootstrap';
|
||||
import { db as testDb } from '../../src/db/database';
|
||||
import { apiDocsEnabled } from '../../src/nest/common/api-docs.kill-switch';
|
||||
import { resetTestDb } from '../helpers/test-db';
|
||||
import { resetDatabase } from '../helpers/reset-database';
|
||||
import { MikroORM } from '@mikro-orm/core';
|
||||
import type { INestApplication } from '@nestjs/common';
|
||||
|
||||
import request from 'supertest';
|
||||
import { describe, it, expect, vi, beforeAll, 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, afterAll } from 'vitest';
|
||||
|
||||
describe('API-DOCS (#1412) — flag-gated OpenAPI surface', () => {
|
||||
let app: INestApplication;
|
||||
@@ -24,18 +19,17 @@ describe('API-DOCS (#1412) — flag-gated OpenAPI surface', () => {
|
||||
let prevFlag: string | undefined;
|
||||
|
||||
beforeAll(async () => {
|
||||
resetTestDb(testDb);
|
||||
prevFlag = process.env.TREK_API_DOCS_ENABLED;
|
||||
process.env.TREK_API_DOCS_ENABLED = 'true';
|
||||
app = await buildApp();
|
||||
instance = app.getHttpAdapter().getInstance();
|
||||
await resetDatabase(app.get(MikroORM));
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
if (prevFlag === undefined) delete process.env.TREK_API_DOCS_ENABLED;
|
||||
else process.env.TREK_API_DOCS_ENABLED = prevFlag;
|
||||
await app.close();
|
||||
testDb.close();
|
||||
});
|
||||
|
||||
it('DOCS-001 — the kill switch parses the boolean-like env family', () => {
|
||||
|
||||
Reference in New Issue
Block a user