import { randomBytes } from 'node:crypto'; export interface E2EContext { baseUrl: string; openBaseUrl: string; rateLimitBaseUrl: string; managerToken: string; terminalToken: string; tenantId: string; actorId: string; terminalActorId: string; appDatabaseUrl: string; migrationDatabaseUrl: string; } declare module 'vitest' { export interface ProvidedContext { e2e: E2EContext; } } const crockford = '0123456789ABCDEFGHJKMNPQRSTVWXYZ'; /** Случайный ULID (время + crypto.randomBytes), чтобы не зависеть от src/. */ export function randomUlid(): string { let time = Date.now(); let timePart = ''; for (let i = 0; i < 10; i += 1) { timePart = crockford[time % 32]! + timePart; time = Math.floor(time / 32); } const bytes = randomBytes(16); let randomPart = ''; for (let i = 0; i < 16; i += 1) randomPart += crockford[bytes[i]! % 32]!; return timePart + randomPart; } /** Синтетическая метка для данных тестов: очевидно не реальные люди/суммы. */ export function synthetic(label: string): string { return `E2E-${label}-${randomBytes(3).toString('hex')}`; }