* refactor(tools): organize internal CLI workflows - Group visual-oracle commands behind a Citty CLI and domain folders\n- Add imported-document visual comparison manifests and pixel-diff outputs\n- Consolidate package-quality checks behind stable check, smoke, and verify commands\n- Remove obsolete visual root aliases and compatibility scripts * fix(tools): validate visual oracle target scope - Validate manifest records, required strings, and optional field types\n- Reject explicit OpenPencil nodes outside the configured page * fix(tools): validate packaged runtime exports
58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
import { afterEach, describe, expect, test } from 'bun:test'
|
|
import { rmSync, writeFileSync } from 'node:fs'
|
|
|
|
import { readVisualOracleManifest } from '#visual/manifest'
|
|
|
|
const path = '/tmp/open-pencil-visual-oracle-manifest-test.json'
|
|
|
|
afterEach(() => rmSync(path, { force: true }))
|
|
|
|
describe('document visual oracle manifest', () => {
|
|
test('reads document targets and visual thresholds', () => {
|
|
writeFileSync(
|
|
path,
|
|
JSON.stringify({
|
|
document: '/tmp/design.fig',
|
|
appURL: 'http://localhost:1420/',
|
|
targets: [
|
|
{
|
|
page: 'Foundations',
|
|
node: 'Effects',
|
|
figmaNodeId: '1:2',
|
|
expectedWidth: 2080,
|
|
minimumPageRoots: 6
|
|
}
|
|
]
|
|
})
|
|
)
|
|
|
|
expect(readVisualOracleManifest(path).targets[0]).toMatchObject({
|
|
page: 'Foundations',
|
|
expectedWidth: 2080,
|
|
minimumPageRoots: 6
|
|
})
|
|
})
|
|
|
|
test('rejects malformed required and optional fields', () => {
|
|
writeFileSync(
|
|
path,
|
|
JSON.stringify({
|
|
document: '/tmp/design.fig',
|
|
appURL: 42,
|
|
targets: [null]
|
|
})
|
|
)
|
|
expect(() => readVisualOracleManifest(path)).toThrow('appURL')
|
|
|
|
writeFileSync(
|
|
path,
|
|
JSON.stringify({
|
|
document: '/tmp/design.fig',
|
|
appURL: 'http://localhost:1420/',
|
|
targets: [{ page: 'Foundations', node: 'Effects', figmaNodeId: '1:2', scale: '2' }]
|
|
})
|
|
)
|
|
expect(() => readVisualOracleManifest(path)).toThrow('scale')
|
|
})
|
|
})
|