import { describe, test, expect } from 'vitest'; import { summarizeCanvas } from './canvas-summary'; const fixture = { ROOT: { type: { resolvedName: 'Container' }, props: { aiName: 'Page Root', node_id: 'ai-root-1' }, nodes: ['n1','n2'], parent: null }, n1: { type: { resolvedName: 'Heading' }, props: { aiName: 'Hero Title', node_id: 'ai-hero-1', text: 'Welcome', level: 1, style: { color: '#fff' } }, nodes: [], parent: 'ROOT' }, n2: { type: { resolvedName: 'HtmlBlock' }, props: { aiName: 'Custom Embed', node_id: 'ai-html-1', code: '
opaque
' }, nodes: [], parent: 'ROOT' }, }; describe('summarizeCanvas', () => { test('one line per node with id and aiName', () => { const out = summarizeCanvas(fixture as any); expect(out).toContain('Container id=ai-root-1'); expect(out).toContain('Heading id=ai-hero-1 name="Hero Title"'); }); test('excludes style props', () => { expect(summarizeCanvas(fixture as any)).not.toContain('color='); }); test('truncates to maxChars', () => { const out = summarizeCanvas(fixture as any, 60); expect(out.length).toBeLessThanOrEqual(60); expect(out).toContain('truncated'); }); });