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:
Maurice
2026-11-17 15:50:49 +01:00
parent 53ab10afdc
commit b11d8d492c
7 changed files with 31 additions and 58 deletions
+10 -6
View File
@@ -1,6 +1,7 @@
import { UserSessions } from '../../src/db/entities/UserSessions.entity';
import type { UserSessionsRepository } from '../../src/db/repositories/UserSessions.repository';
import { SessionsService } from '../../src/nest/sessions/sessions.service';
import type { FactoryOrm } from './factories/context';
import { findRows } from './factories/rows';
import { sharedTestOrm } from './test-uow';
@@ -26,12 +27,15 @@ export async function sessionRows(
db: Database.Database,
userId: number,
): Promise<{ id: string; revoked_at: string | null; expires_at: string; user_agent: string | null }[]> {
const rows = await findRows(
await sharedTestOrm(db),
UserSessions,
{ user: userId },
{ created_at: 'asc', id: 'asc' },
);
return sessionRowsOf(await sharedTestOrm(db), userId);
}
/** The session rows of a user, oldest first, read through the given ORM (a booted app's, on either engine). */
export async function sessionRowsOf(
orm: FactoryOrm,
userId: number,
): Promise<{ id: string; revoked_at: string | null; expires_at: string; user_agent: string | null }[]> {
const rows = await findRows(orm, UserSessions, { user: userId }, { created_at: 'asc', id: 'asc' });
return rows.map(({ id, revoked_at, expires_at, user_agent }) => ({
id,
revoked_at: revoked_at ?? null,