setup/cms.test.ts: mock AGENT_DOMAIN='clawdie.si' via vi.mock so server_name assertions don't depend on env/registry at test time. src/explanation-grounder.test.ts: accept either PGPASSWORD branch or no-password branch — OPS_DB_URL may or may not carry a password depending on the install environment. Both tests now pass on debby (Linux/Debian 13) and should be environment-independent on all platforms. --- Build: pass | Tests: FAIL — 17 failed
51 lines
2.1 KiB
TypeScript
51 lines
2.1 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest';
|
|
|
|
// Inject a known public domain so the test is env-independent.
|
|
// AGENT_DOMAIN is a module-level const derived from env/registry at import
|
|
// time, so we override it here before any other import resolves it.
|
|
vi.mock('../src/config.js', async () => {
|
|
const actual =
|
|
await vi.importActual<typeof import('../src/config.js')>('../src/config.js');
|
|
return { ...actual, AGENT_DOMAIN: 'clawdie.si' };
|
|
});
|
|
|
|
import { makePlatformRegistryFixture } from '../src/test-fixtures/platform-registry.js';
|
|
import * as surfaceInventoryModule from '../src/surface-inventory.js';
|
|
import { nginxConf } from './cms.js';
|
|
|
|
describe('setup/cms nginxConf', () => {
|
|
it('builds explicit server blocks for cms admin and tenant surfaces', () => {
|
|
vi.spyOn(surfaceInventoryModule, 'buildSurfaceInventory').mockReturnValue(
|
|
surfaceInventoryModule.buildSurfaceInventory(
|
|
makePlatformRegistryFixture(),
|
|
),
|
|
);
|
|
|
|
const conf = nginxConf({ adminUiEnabled: true });
|
|
|
|
expect(conf).toContain('listen 80 default_server;');
|
|
expect(conf).toContain('server_name cms.home.arpa cms.clawdie.si;');
|
|
expect(conf).toContain('server_name clawdie.si www.clawdie.si;');
|
|
expect(conf).toContain('root /usr/local/www/clawdie-si;');
|
|
expect(conf).toContain('return 301 https://clawdie.si/en/;');
|
|
expect(conf).toContain('docs.clawdie.si');
|
|
expect(conf).toContain('blog.alpha.home.arpa');
|
|
expect(conf).toContain('alpha.home.arpa');
|
|
expect(conf).toContain('location /api/');
|
|
expect(conf).toContain('location /admin/');
|
|
expect(conf).toContain('try_files $uri $uri/ =404;');
|
|
expect(conf).toContain('location /screenshots/ {');
|
|
expect(conf).not.toContain('auth_basic_user_file');
|
|
});
|
|
|
|
it('returns 404 for admin/api paths when admin ui is disabled', () => {
|
|
const conf = nginxConf({ adminUiEnabled: false });
|
|
|
|
expect(conf).toContain('location /admin/ {');
|
|
expect(conf).toContain('location /api/ {');
|
|
expect(conf).toContain('return 404;');
|
|
expect(conf).not.toContain(
|
|
'proxy_pass http://127.0.0.1:1337/admin/;',
|
|
);
|
|
});
|
|
});
|