36 lines
1.5 KiB
TypeScript
36 lines
1.5 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { exportFrame } from '@/lib/wysiwyg/export'
|
|
import type { Frame } from '@/lib/wysiwyg/schema'
|
|
|
|
function baseFrame(): Frame {
|
|
return {
|
|
id: 'f', width: 400, height: 300, background: '#111111',
|
|
layers: [{ id: 'l1', name: 'Base', visible: true, locked: false, objects: [] }],
|
|
}
|
|
}
|
|
|
|
describe('wysiwyg export - form tokens deep regression', () => {
|
|
it('contains ring/disabled tokens and applies across selectors', () => {
|
|
const out = exportFrame(baseFrame())
|
|
const css = out.css
|
|
// tokens
|
|
expect(css).toMatch(/:root[^}]*--ring:/)
|
|
expect(css).toMatch(/:root[^}]*--ring-offset:/)
|
|
expect(css).toMatch(/:root[^}]*--disabled-bg:/)
|
|
expect(css).toMatch(/:root[^}]*--disabled-fg:/)
|
|
// usages
|
|
expect(css).toMatch(/:focus-visible\s*{[^}]*outline:2px solid var\(--ring\)/)
|
|
expect(css).toMatch(/:focus-visible\s*{[^}]*outline-offset:var\(--ring-offset\)/)
|
|
expect(css).toMatch(/input:disabled,select:disabled,textarea:disabled\s*{[^}]*background:var\(--disabled-bg\)/)
|
|
expect(css).toMatch(/input\[readonly\],select\[readonly\],textarea\[readonly\]\s*{[^}]*color:var\(--disabled-fg\)/)
|
|
})
|
|
|
|
it('themes define overrides without breaking base var() usage', () => {
|
|
const out = exportFrame(baseFrame())
|
|
const css = out.css
|
|
expect(css).toMatch(/\[data-theme="light"\][^{]*{[^}]*--bg:/)
|
|
expect(css).toMatch(/\[data-theme="dark"\][^{]*{[^}]*--bg:/)
|
|
expect(css).toMatch(/\.frame\s*{[^}]*background:var\(--bg\)/)
|
|
})
|
|
})
|