| 1 | import { describe, expect, it } from 'vitest' |
| 2 | import { normalizeSelectedElementRuntimeContext } from '../../../src/main/generation/context' |
| 3 | |
| 4 | describe('normalizeSelectedElementRuntimeContext', () => { |
| 5 | it('accepts only the bounded safe property subset before an agent sees it', () => { |
| 6 | expect( |
| 7 | normalizeSelectedElementRuntimeContext({ |
| 8 | classList: ['metric-card', 'arcsin1-presentation-editor-selected'], |
| 9 | attributes: { |
| 10 | 'data-block-id': 'revenue-card', |
| 11 | onclick: 'ignore this', |
| 12 | srcdoc: '<script>bad()</script>' |
| 13 | }, |
| 14 | inlineStyle: { |
| 15 | color: { value: '#18324a', priority: 'important' }, |
| 16 | 'bad property': { value: 'ignore' } |
| 17 | }, |
| 18 | computedStyle: { |
| 19 | display: 'grid', |
| 20 | 'border-radius': '16px', |
| 21 | cursor: 'pointer' |
| 22 | }, |
| 23 | bounds: { x: -999999, y: 3.456, width: 450.123, height: -20 } |
| 24 | }) |
| 25 | ).toEqual({ |
| 26 | classList: ['metric-card'], |
| 27 | attributes: { 'data-block-id': 'revenue-card' }, |
| 28 | inlineStyle: { color: { value: '#18324a', priority: 'important' } }, |
| 29 | computedStyle: { display: 'grid', 'border-radius': '16px' }, |
| 30 | bounds: { x: -100000, y: 3.46, width: 450.12, height: 0 } |
| 31 | }) |
| 32 | }) |
| 33 | }) |
| 34 |