mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-19 05:26:47 +00:00
724c88c201
A mechanical prettier --write over server/src, server/tests, server/scripts and shared/src with the workspaces' .prettierrc; nothing but layout and import order changes, and every file keeps the same set of imports. shared is formatted throughout and its format baseline is empty. The server baseline keeps the 35 files that Prettier would grow past their lint:size limit (they need a split first, which is not a formatting change), and the generated entity files stay as their generator writes them.
53 lines
2.0 KiB
TypeScript
53 lines
2.0 KiB
TypeScript
/**
|
|
* SCHED-GATE — the no-timers-in-the-harness regression test. buildApp() is
|
|
* shared with every integration/e2e suite, and job providers register their
|
|
* crons from onApplicationBootstrap, which app.init() fires on every boot.
|
|
* This proves the CronRegistrarService NODE_ENV=test gate holds: a full
|
|
* harness boot registers zero cron jobs, intervals or timeouts, and closing
|
|
* the app leaves nothing behind. If this ever goes red, some job bypassed the
|
|
* registrar (or used a @Cron decorator) and every suite is now running real
|
|
* timers.
|
|
*/
|
|
import { buildApp } from '../../src/bootstrap';
|
|
import { db as testDb } from '../../src/db/database';
|
|
import { CronRegistrarService } from '../../src/nest/scheduling/cron-registrar.service';
|
|
import type { INestApplication } from '@nestjs/common';
|
|
import { SchedulerRegistry } from '@nestjs/schedule';
|
|
|
|
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());
|
|
});
|
|
|
|
describe('SCHED-GATE — the harness boots without scheduling anything', () => {
|
|
let app: INestApplication;
|
|
|
|
beforeAll(async () => {
|
|
app = await buildApp();
|
|
});
|
|
|
|
afterAll(() => {
|
|
testDb.close();
|
|
});
|
|
|
|
it('SCHED-GATE-001 — the registrar reports the test gate closed', () => {
|
|
expect(app.get(CronRegistrarService).isEnabled()).toBe(false);
|
|
});
|
|
|
|
it('SCHED-GATE-002 — a full app boot registers zero cron jobs, intervals and timeouts', () => {
|
|
const registry = app.get(SchedulerRegistry);
|
|
expect(registry.getCronJobs().size).toBe(0);
|
|
expect(registry.getIntervals()).toHaveLength(0);
|
|
expect(registry.getTimeouts()).toHaveLength(0);
|
|
expect(app.get(CronRegistrarService).jobCount).toBe(0);
|
|
});
|
|
|
|
it('SCHED-GATE-003 — app.close() leaves the registrar empty (shutdown parity)', async () => {
|
|
const registrar = app.get(CronRegistrarService);
|
|
await app.close();
|
|
expect(registrar.jobCount).toBe(0);
|
|
});
|
|
});
|