- Add AST-based lint checks for broad unknown object assertions and local JsonObject aliases - Centralize JsonObject in core and package-local MCP RPC JSON typing - Replace baseline Record<string, unknown> assertions with named shared/domain types
79 lines
2.2 KiB
TypeScript
79 lines
2.2 KiB
TypeScript
import { describe, expect, test } from 'bun:test'
|
|
|
|
import { exportFigFile, parseFigFile, SceneGraph } from '@open-pencil/core'
|
|
|
|
import { expectDefined } from '#tests/helpers/assert'
|
|
|
|
import { pageId, toKiwi } from '../helpers'
|
|
|
|
describe('Fix 2: frameMaskDisabled is inverse of clipsContent', () => {
|
|
test('FRAME without clipsContent gets frameMaskDisabled=true', () => {
|
|
const graph = new SceneGraph()
|
|
const node = graph.createNode('FRAME', pageId(graph), {
|
|
name: 'Frame',
|
|
x: 0,
|
|
y: 0,
|
|
width: 100,
|
|
height: 100
|
|
})
|
|
|
|
const changes = toKiwi(node, graph)
|
|
expect(changes[0].frameMaskDisabled).toBe(true)
|
|
})
|
|
|
|
test('FRAME with clipsContent=true gets frameMaskDisabled=false', () => {
|
|
const graph = new SceneGraph()
|
|
const node = graph.createNode('FRAME', pageId(graph), {
|
|
name: 'Clipping',
|
|
x: 0,
|
|
y: 0,
|
|
width: 100,
|
|
height: 100,
|
|
clipsContent: true
|
|
})
|
|
|
|
const changes = toKiwi(node, graph)
|
|
expect(changes[0].frameMaskDisabled).toBe(false)
|
|
})
|
|
|
|
test('FRAME with clipsContent=false gets frameMaskDisabled=true', () => {
|
|
const graph = new SceneGraph()
|
|
const node = graph.createNode('FRAME', pageId(graph), {
|
|
name: 'NoClip',
|
|
x: 0,
|
|
y: 0,
|
|
width: 100,
|
|
height: 100,
|
|
clipsContent: false
|
|
})
|
|
|
|
const changes = toKiwi(node, graph)
|
|
expect(changes[0].frameMaskDisabled).toBe(true)
|
|
})
|
|
|
|
test('clipsContent roundtrips through export/parse', async () => {
|
|
const graph = new SceneGraph()
|
|
graph.createNode('FRAME', pageId(graph), {
|
|
name: 'ClipFrame',
|
|
x: 0,
|
|
y: 0,
|
|
width: 100,
|
|
height: 100,
|
|
clipsContent: true
|
|
})
|
|
|
|
const exported = await exportFigFile(graph)
|
|
const reimported = await parseFigFile(exported.buffer as ArrayBuffer)
|
|
|
|
const frame = expectDefined(
|
|
[...reimported.nodes.values()].find((n) => n.name === 'ClipFrame'),
|
|
'ClipFrame'
|
|
)
|
|
expect(frame.clipsContent).toBe(true)
|
|
})
|
|
})
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Fix 3 — bordersTakeSpace writes strokesIncludedInLayout
|
|
// ---------------------------------------------------------------------------
|