fix(test): make config-identity tenant fallback test self-contained

The test was coupling to whatever TENANT_ID happened to be in the local
.env file, which is absent in this environment. Mocks readEnvFile to
provide a controlled deployment env so the test is deterministic everywhere.

Also removes scripts/sync-docs.mjs which was superseded by
sync-public-docs.mjs in acc868a and is no longer called.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---
Build: pass | Tests: FAIL — Tests  7 failed | 2015 passed (2022)
This commit is contained in:
Operator & Claude Code 2026-04-28 22:16:51 +02:00
parent 3c401fbfb1
commit 842f5f6757
2 changed files with 11 additions and 34 deletions

View file

@ -1,34 +0,0 @@
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const projectRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const repoRoot = path.resolve(projectRoot, '../../..');
const docsSource = path.join(repoRoot, 'docs/public');
const docsTarget = path.join(projectRoot, 'src/content/docs/en');
// Directories that are authored in docs/public and rendered by Astro.
// Astro-only dirs (guides, roadmap) are intentionally excluded — they live only in the Astro tree.
const SYNC_DIRS = ['architecture', 'install', 'operate', 'reference'];
let copied = 0;
for (const dir of SYNC_DIRS) {
const src = path.join(docsSource, dir);
const dst = path.join(docsTarget, dir);
if (!fs.existsSync(src)) continue;
fs.mkdirSync(dst, { recursive: true });
for (const file of fs.readdirSync(src)) {
if (!file.endsWith('.md') && !file.endsWith('.mdx')) continue;
const srcContent = fs.readFileSync(path.join(src, file), 'utf-8');
const dstPath = path.join(dst, file);
const dstContent = fs.existsSync(dstPath) ? fs.readFileSync(dstPath, 'utf-8') : null;
if (srcContent !== dstContent) {
fs.writeFileSync(dstPath, srcContent, 'utf-8');
console.log(`sync-docs: ${dir}/${file}`);
copied++;
}
}
}
console.log(copied === 0 ? 'sync-docs: up to date' : `sync-docs: ${copied} file(s) updated`);

View file

@ -59,6 +59,15 @@ describe('config identity', () => {
it('falls back to the configured runtime tenant when TENANT_ID is unset', async () => {
process.env.ASSISTANT_NAME = 'Bob';
// Simulate a deployment .env that has TENANT_ID set without exposing it
// in process.env — this is exactly what readEnvFile is for.
vi.doMock('./env.js', async () => {
const actual = await vi.importActual<typeof import('./env.js')>('./env.js');
return {
...actual,
readEnvFile: () => ({ TENANT_ID: 'mevy', AGENT_DOMAIN: 'home.arpa' }),
};
});
const config = await import('./config.js');
@ -66,6 +75,8 @@ describe('config identity', () => {
expect(config.TENANT_DISPLAY_NAME).toBe('Bob');
expect(config.ASSISTANT_NAME).toBe('Bob');
expect(config.AGENT_DOMAIN).toBe('home.arpa');
vi.doUnmock('./env.js');
});
it('allows platform runtime user to differ from the tenant', async () => {