catalog: omit the wall-clock-derived Countdown.targetDate default so the generated catalog (and drift test) no longer flip daily

Add a date-independence test (freezes Date at two different days via a preload).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
shadowdaoandClaude Sonnet 5.5 committed 2026-11-01 16:28:48 -08:00
1 parent 96670b94f8
commit 01a78c9b3d
3 files changed
+31 -3

No files matched your search

+13 -2
View File
@@ -26,8 +26,11 @@ const craftRoot: string = path.resolve(decodeURIComponent(new URL('.', import.me
const committedPath: string = proc.env.SITESMITH_CATALOG_FILE
?? path.resolve(craftRoot, '../../whp/web-files/libs/sitesmith-catalog.generated.json');
function regenerate(): string {
return execFileSync(proc.execPath, ['scripts/gen-sitesmith-catalog.mjs', '--stdout'], {
function regenerate(fakeNow?: string): string {
const args = ['scripts/gen-sitesmith-catalog.mjs', '--stdout'];
if (fakeNow) args.unshift('-r', path.join(craftRoot, 'scripts/fake-date-preload.cjs'));
return execFileSync(proc.execPath, args, {
env: fakeNow ? { ...proc.env, FAKE_NOW: fakeNow } : proc.env,
cwd: craftRoot, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024, timeout: 120_000,
});
}
@@ -47,6 +50,14 @@ describe('sitesmith catalog', () => {
expect(fresh).toBe(committed);
}, 130_000);
test('catalog is date-independent (Countdown default date is volatile and must not leak in)', () => {
const a = regenerate('2026-12-01T12:00:00Z');
const b = regenerate('2027-03-09T12:00:00Z');
expect(a).toBe(b);
expect(JSON.parse(a).components.Countdown.props.targetDate.default).toBeUndefined();
expect(a).not.toMatch(/"\d{4}-\d{2}-\d{2}"/);
}, 130_000);
test('catalog covers every resolver component, with derived facts', () => {
const cat = JSON.parse(regenerate());
const resolver = fs.readFileSync(path.join(craftRoot, 'src/components/resolver.ts'), 'utf8');