mirror of
https://github.com/nexu-io/open-design.git
synced 2026-10-27 09:51:12 +01:00
* docs(daemon): add agent guidance * refactor(daemon): organize source modules * chore(guard): update daemon design system import * refactor(daemon): shorten domain module filenames * fix(daemon): correct pitch-deck manifest path after test move The pitch-deck manifest test moved one directory deeper into tests/design-systems/ but kept the old '../../..' repoRoot, resolving to apps/ instead of the repo root and failing to find plugins/_official/examples/html-ppt-pitch-deck/open-design.json. * fix(daemon): retarget media model verifier Generated-By: looper 0.9.10 (runner=fixer, agent=codex) * docs(daemon): refresh AGENTS legacy paths after module reorg * test(e2e): allow manual edit P0 CI scaling Generated-By: looper 0.9.10 (runner=fixer, agent=codex) * test(daemon): fix frontmatter import path Generated-By: looper 0.9.10 (runner=fixer, agent=opencode) * fix(web): avoid replaying legacy terminal runs Generated-By: looper 0.9.10 (runner=fixer, agent=opencode) * fix(web): preserve legacy terminal replay recovery Generated-By: looper 0.9.10 (runner=fixer, agent=opencode) * fix(daemon): correct live-artifacts test data root * fix(daemon): cover moved route registrars in context contract Generated-By: looper 0.9.10 (runner=fixer, agent=opencode) * fix(daemon): restore moved runtime artifact imports Generated-By: looper 0.9.10 (runner=fixer, agent=opencode)
100 lines
3.1 KiB
TypeScript
100 lines
3.1 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { inferLegacyManifest, validateArtifactManifestInput } from '../../src/artifacts/manifest.js';
|
|
|
|
function validBase() {
|
|
return {
|
|
kind: 'html',
|
|
renderer: 'html',
|
|
title: 'Test',
|
|
exports: ['html'],
|
|
};
|
|
}
|
|
|
|
describe('validateArtifactManifestInput', () => {
|
|
it('rejects empty exports', () => {
|
|
const res = validateArtifactManifestInput({ ...validBase(), exports: [] }, 'index.html');
|
|
expect(res.ok).toBe(false);
|
|
});
|
|
|
|
it('rejects invalid kind and renderer and export', () => {
|
|
expect(
|
|
validateArtifactManifestInput(
|
|
{ ...validBase(), kind: 'evil-kind', renderer: 'html', exports: ['html'] },
|
|
'index.html',
|
|
).ok,
|
|
).toBe(false);
|
|
expect(
|
|
validateArtifactManifestInput(
|
|
{ ...validBase(), kind: 'html', renderer: 'evil-renderer', exports: ['html'] },
|
|
'index.html',
|
|
).ok,
|
|
).toBe(false);
|
|
expect(
|
|
validateArtifactManifestInput(
|
|
{ ...validBase(), kind: 'html', renderer: 'html', exports: ['exe'] },
|
|
'index.html',
|
|
).ok,
|
|
).toBe(false);
|
|
});
|
|
|
|
it('rejects traversal in supportingFiles', () => {
|
|
const res = validateArtifactManifestInput(
|
|
{ ...validBase(), supportingFiles: ['../secret.txt'] },
|
|
'index.html',
|
|
);
|
|
expect(res.ok).toBe(false);
|
|
});
|
|
|
|
it('defaults status to complete when missing', () => {
|
|
const res = validateArtifactManifestInput(validBase(), 'index.html');
|
|
expect(res.ok).toBe(true);
|
|
if (res.ok) expect(res.value?.status).toBe('complete');
|
|
});
|
|
|
|
it('preserves valid status values', () => {
|
|
const res = validateArtifactManifestInput({ ...validBase(), status: 'streaming' }, 'index.html');
|
|
expect(res.ok).toBe(true);
|
|
if (res.ok) expect(res.value?.status).toBe('streaming');
|
|
});
|
|
|
|
it('preserves an existing updatedAt timestamp when requested', () => {
|
|
const res = validateArtifactManifestInput(
|
|
{ ...validBase(), updatedAt: '2026-05-01T00:00:00.000Z' },
|
|
'index.html',
|
|
{ preserveUpdatedAt: true },
|
|
);
|
|
|
|
expect(res.ok).toBe(true);
|
|
if (res.ok) expect(res.value?.updatedAt).toBe('2026-05-01T00:00:00.000Z');
|
|
});
|
|
|
|
it('stamps updatedAt at validation time by default', () => {
|
|
const res = validateArtifactManifestInput(
|
|
{ ...validBase(), updatedAt: '2026-05-01T00:00:00.000Z' },
|
|
'index.html',
|
|
);
|
|
|
|
expect(res.ok).toBe(true);
|
|
if (res.ok) expect(res.value?.updatedAt).not.toBe('2026-05-01T00:00:00.000Z');
|
|
});
|
|
});
|
|
|
|
describe('inferLegacyManifest', () => {
|
|
it('infers markdown manifest for .md files', () => {
|
|
const out = inferLegacyManifest('README.md');
|
|
expect(out?.kind).toBe('markdown-document');
|
|
expect(out?.renderer).toBe('markdown');
|
|
expect(out?.status).toBe('complete');
|
|
expect(out?.exports).toEqual(['md', 'html', 'pdf', 'zip']);
|
|
});
|
|
|
|
it('infers svg manifest for .svg files', () => {
|
|
const out = inferLegacyManifest('logo.svg');
|
|
expect(out?.kind).toBe('svg');
|
|
expect(out?.renderer).toBe('svg');
|
|
expect(out?.status).toBe('complete');
|
|
expect(out?.exports).toEqual(['svg', 'zip']);
|
|
});
|
|
});
|