krona-staff/tests/unit/config.test.ts
Ochenstarik d45bee960a
Some checks are pending
ci / verify (push) Waiting to run
fix: harden terminal recovery and deployment
2026-09-18 11:10:28 +07:00

31 lines
1.1 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { loadConfig } from '../../src/config.js';
const base = {
DATABASE_URL: 'postgres://localhost/staff',
STANDALONE_TENANT_ID: '01J00000000000000000000000',
STANDALONE_ACTOR_ID: '01J00000000000000000000001',
};
describe('runtime modes', () => {
it('allows the compatible standalone adapter', () =>
expect(loadConfig(base).STAFF_RUNTIME_MODE).toBe('standalone'));
it('fails closed when platform contracts are missing', () =>
expect(() => loadConfig({ ...base, STAFF_RUNTIME_MODE: 'platform' })).toThrow(
/PLATFORM_GATEWAY_URL/,
));
it('rejects standalone mode in production', () =>
expect(() => loadConfig({ ...base, NODE_ENV: 'production' })).toThrow(
/standalone is not allowed/,
));
it('treats empty optional platform variables as absent in compose', () =>
expect(
loadConfig({
...base,
PLATFORM_GATEWAY_URL: '',
PLATFORM_JWT_ISSUER: '',
PLATFORM_JWT_AUDIENCE: '',
PLATFORM_JWKS_URL: '',
}).PLATFORM_GATEWAY_URL,
).toBeUndefined());
});