mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-19 13:36:48 +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.
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
/**
|
|
* Public config e2e — verifies /api/config is reachable WITHOUT authentication
|
|
* (it has no guard) and returns the server default language. No db needed.
|
|
*/
|
|
import { DEFAULT_LANGUAGE } from '../../src/config';
|
|
import { TrekExceptionFilter } from '../../src/nest/common/trek-exception.filter';
|
|
import { ConfigModule } from '../../src/nest/config/config.module';
|
|
import { Test } from '@nestjs/testing';
|
|
|
|
import type { Server } from 'http';
|
|
import request from 'supertest';
|
|
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
|
|
|
|
describe('Public config e2e (no auth guard)', () => {
|
|
let server: Server;
|
|
let app: Awaited<ReturnType<typeof build>>;
|
|
|
|
async function build() {
|
|
const moduleRef = await Test.createTestingModule({ imports: [ConfigModule] }).compile();
|
|
const nest = moduleRef.createNestApplication();
|
|
nest.useGlobalFilters(new TrekExceptionFilter());
|
|
await nest.init();
|
|
return nest;
|
|
}
|
|
|
|
beforeAll(async () => {
|
|
app = await build();
|
|
server = app.getHttpServer();
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await app.close();
|
|
});
|
|
|
|
it('200 with the default language and no cookie required', async () => {
|
|
const res = await request(server).get('/api/config');
|
|
expect(res.status).toBe(200);
|
|
expect(res.body).toEqual({ defaultLanguage: DEFAULT_LANGUAGE });
|
|
});
|
|
});
|