test(engine): move root tests into domains
This commit is contained in:
parent
937577c0e6
commit
6eb50affc4
|
|
@ -201,8 +201,8 @@ const strictTestFilePlacement = createFileRule('open-pencil/strict-test-file-pla
|
|||
if (sourceRel.startsWith('tests/engine/')) {
|
||||
if (sourceRel.endsWith('.test.ts')) return null
|
||||
if (sourceRel.endsWith('/helpers.ts') || sourceRel.endsWith('.bench.ts')) return null
|
||||
if (path.basename(sourceRel).startsWith('visual-')) return null
|
||||
return 'Engine/unit tests must live under tests/engine/** and use *.test.ts; helpers.ts, *.bench.ts, and visual-* support scripts are allowed.'
|
||||
if (/\/visual\/[^/]+\.ts$/.test(sourceRel)) return null
|
||||
return 'Engine/unit tests must live under tests/engine/** and use *.test.ts; helpers.ts, *.bench.ts, and domain visual support scripts are allowed.'
|
||||
}
|
||||
if (sourceRel.startsWith('tests/helpers/')) return null
|
||||
return 'Tests must live under tests/e2e/** (*.spec.ts), tests/engine/** (*.test.ts), or tests/helpers/**.'
|
||||
|
|
@ -239,8 +239,13 @@ const noMisplacedEngineTestDomainPaths = createFileRule(
|
|||
'open-pencil/no-misplaced-engine-test-domain-paths',
|
||||
(sourceRel) => {
|
||||
const redirect = ENGINE_TEST_DOMAIN_REDIRECTS.find(({ from }) => sourceRel.startsWith(from))
|
||||
if (!redirect) return null
|
||||
return `Move tests from ${redirect.from} under ${redirect.to} to mirror ${redirect.source}.`
|
||||
if (redirect) {
|
||||
return `Move tests from ${redirect.from} under ${redirect.to} to mirror ${redirect.source}.`
|
||||
}
|
||||
if (/^tests\/engine\/[^/]+\.test\.ts$/.test(sourceRel)) {
|
||||
return 'Move root-level engine tests under a domain folder that mirrors the source module under test.'
|
||||
}
|
||||
return null
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -291,8 +291,8 @@ describe('Doc 02 — Formula Deconstruction: Static Code Claims', () => {
|
|||
// ============================================================
|
||||
|
||||
describe('Doc 03 — Artifact Analysis: Static + Runtime Verification', () => {
|
||||
test('C03-01: visual-inner-shadow-counter.ts exists and checks for right-edge shadow', () => {
|
||||
const visualTestPath = repoTestPath('engine/visual-inner-shadow-counter.ts')
|
||||
test('C03-01: render visual inner-shadow counter script exists and checks for right-edge shadow', () => {
|
||||
const visualTestPath = repoTestPath('engine/render/canvas/visual/inner-shadow-counter.ts')
|
||||
const src = readFileSync(visualTestPath, 'utf-8')
|
||||
expect(src).toContain('hasShadowOnRightInnerEdge')
|
||||
expect(src).toContain("t.color === 'black'")
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ async function main() {
|
|||
}
|
||||
}
|
||||
|
||||
console.log('Transitions at centerY:', transitions)
|
||||
console.warn('Transitions at centerY:', transitions)
|
||||
|
||||
// Expected transitions for a physically correct inner shadow (light from left):
|
||||
// 1. blue -> black (left outer edge, shadow starts)
|
||||
|
|
@ -120,7 +120,7 @@ async function main() {
|
|||
const data = image.encodeToBytes(ck.ImageFormat.PNG, 100)
|
||||
if (data) {
|
||||
await Bun.write('scratch/escher-trap-detected.png', data)
|
||||
console.log('Saved scratch/escher-trap-detected.png')
|
||||
console.warn('Saved scratch/escher-trap-detected.png')
|
||||
}
|
||||
surface.delete()
|
||||
|
||||
|
|
@ -131,7 +131,7 @@ async function main() {
|
|||
)
|
||||
process.exit(1)
|
||||
} else {
|
||||
console.log(
|
||||
console.warn(
|
||||
'✅ PASSED: Physically accurate shadow detected on the right inner edge of the counter'
|
||||
)
|
||||
process.exit(0)
|
||||
|
|
@ -160,7 +160,7 @@ async function main() {
|
|||
await mkdir(outputDir, { recursive: true })
|
||||
|
||||
const matrix = generateMatrix()
|
||||
console.log(`Generated ${matrix.length} test cases`)
|
||||
console.warn(`Generated ${matrix.length} test cases`)
|
||||
|
||||
let generated = 0
|
||||
let failed = 0
|
||||
|
|
@ -234,7 +234,7 @@ async function main() {
|
|||
renderer.destroy()
|
||||
}
|
||||
|
||||
console.log(`\nResult: ${generated} generated, ${failed} failed out of ${matrix.length}`)
|
||||
console.warn(`\nResult: ${generated} generated, ${failed} failed out of ${matrix.length}`)
|
||||
}
|
||||
|
||||
main()
|
||||
|
|
@ -19,7 +19,7 @@ async function main() {
|
|||
|
||||
// Load Inter font from public dir
|
||||
const fontPath = join(process.cwd(), 'public/Inter-SemiBold.ttf')
|
||||
console.log('Loading font from:', fontPath)
|
||||
console.warn('Loading font from:', fontPath)
|
||||
const fontData = await readFile(fontPath)
|
||||
fontManager.markLoaded(
|
||||
'Inter',
|
||||
|
|
@ -62,9 +62,9 @@ async function main() {
|
|||
renderer.fontProvider = fontProvider
|
||||
renderer.fontsLoaded = true
|
||||
|
||||
console.log('Node created:', nodeId)
|
||||
console.log('Font loaded for node:', renderer.isNodeFontLoaded(textNode))
|
||||
console.log('Absolute position:', graph.getAbsolutePosition(nodeId))
|
||||
console.warn('Node created:', nodeId)
|
||||
console.warn('Font loaded for node:', renderer.isNodeFontLoaded(textNode))
|
||||
console.warn('Absolute position:', graph.getAbsolutePosition(nodeId))
|
||||
|
||||
// Render with scale 2
|
||||
const data = renderNodesToImage(ck, renderer, graph, pageId, [nodeId], {
|
||||
|
|
@ -75,7 +75,7 @@ async function main() {
|
|||
surface.delete()
|
||||
|
||||
if (data && data.length > 2000) {
|
||||
console.log(`✅ Generated scratch/text-inner-shadow-verification.png (${data.length} bytes)`)
|
||||
console.warn(`✅ Generated scratch/text-inner-shadow-verification.png (${data.length} bytes)`)
|
||||
} else {
|
||||
console.error(`❌ Failed to generate useful image (size: ${data?.length ?? 0} bytes)`)
|
||||
if (data) {
|
||||
Loading…
Reference in a new issue