open-design/apps/web/tests/produced-files.test.ts
wuyangfan a094bc13b6 fix(web): add mime field to produced-files test fixtures
Fixes Preflight typecheck failure on #3089 PR.
2026-05-27 22:16:17 +08:00

38 lines
1.1 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import {
filterAgentAttributedProjectFiles,
isUserSketchProjectFile,
} from '../src/produced-files';
import type { ProjectFile } from '../src/types';
function file(name: string, kind: ProjectFile['kind']): ProjectFile {
return {
name,
path: name,
size: 1,
mtime: 0,
kind,
mime: kind === 'sketch' ? 'application/json' : 'text/html',
};
}
describe('isUserSketchProjectFile', () => {
it('returns true for sketch workspace files', () => {
expect(isUserSketchProjectFile(file('board.sketch.json', 'sketch'))).toBe(true);
});
it('returns false for agent-generated artifacts', () => {
expect(isUserSketchProjectFile(file('index.html', 'html'))).toBe(false);
});
});
describe('filterAgentAttributedProjectFiles', () => {
it('drops sketch files from turn output attribution (#3089)', () => {
const filtered = filterAgentAttributedProjectFiles([
file('deck.html', 'html'),
file('notes.sketch.json', 'sketch'),
]);
expect(filtered.map((entry) => entry.name)).toEqual(['deck.html']);
});
});