openpencil/tools/generate/visual-oracles/tests/document/manifest.test.ts
Danila Poyarkov 1aa10a4fed
build(tools): group tools by role and gate them like the rest of the repo (#791)
Tools live under tools/<role>/<domain> (checks, generate, release, ci, dev), every tool is a workspace named @open-pencil/<domain>-tools, a shared tools/tsconfig.json backs the new check:tools gate that fixed 55 latent type errors, test:tools runs through bun --filter, the placement check is its own checks/test-homes package, and every tool resolves the repository through resolveWorkspaceRoot. Bun, Node, and mdast types live in a tools-root workspace so they never reach the app program.
2026-09-30 05:00:31 +04:00

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')
})
})