Files
TREK/server/tests/unit/nest/llm-parse/llm-capabilities.controller.test.ts
T
Maurice cc79f561e5 refactor(auth): guards, auth decorators and ephemeral tokens move into an auth-core kernel
JwtAuthGuard, OptionalJwtAuthGuard, CookieAuthGuard, AdminGuard, the global
and MFA guards, @CurrentUser, @Public, JWT verification and the ephemeral
token service lived in the auth domain, so every controller that checked a
session depended on the whole account module and its imports. They import
no domain themselves; under src/nest/auth-core they are shared kernel like
common/, every importer points there directly, and AtlasModule and
NotificationsModule stop importing AuthModule, which they only did for the
demo gate. lint:boundaries counts auth-core as kernel: 57 fewer cyclic
domain edges, the largest cycle shrinks from 46 to 40 domains.
2026-10-10 20:15:58 +02:00

21 lines
1.1 KiB
TypeScript

import { describe, it, expect, vi } from 'vitest';
import { GUARDS_METADATA } from '@nestjs/common/constants';
import { LlmCapabilitiesController } from '../../../../src/nest/llm-parse/llm-capabilities.controller';
import { JwtAuthGuard } from '../../../../src/nest/auth-core/jwt-auth.guard';
import type { LlmParseService } from '../../../../src/nest/llm-parse/llm-parse.service';
import type { User } from '../../../../src/types';
describe('LlmCapabilitiesController', () => {
it("answers whether the caller's model reads images", async () => {
const readsImages = vi.fn(async (id: number) => id === 1);
const c = new LlmCapabilitiesController({ readsImages } as unknown as LlmParseService);
await expect(c.capabilities({ id: 1 } as User)).resolves.toEqual({ images: true });
await expect(c.capabilities({ id: 2 } as User)).resolves.toEqual({ images: false });
expect(readsImages).toHaveBeenCalledWith(2);
});
it('needs a session', () => {
expect(Reflect.getMetadata(GUARDS_METADATA, LlmCapabilitiesController)).toContain(JwtAuthGuard);
});
});