* test(core): move the fig round-trip suite into the package test home
The reader change added `verifier-contracts.test.ts` under
`tests/engine` and grew the migration baseline to admit it, which the
testing architecture forbids: new tests go to the canonical home and
the baseline only shrinks. It also started
`packages/core/tests/io/formats/fig/roundtrip/`, leaving two homes for
one domain.
These tests drive Core's exporter, so Core's home is the canonical one.
The directory moves whole — eleven files, its helpers and raw verifiers
with it — and picks up the local `assert`, `traversal`, `test-utils`
and fixture helpers already there. The baseline loses nine entries.
* refactor(core): address test helpers by alias instead of drilling
`open-pencil/no-deep-parent-relative-imports` already forbids `../../`
drilling, but `lint:structure` names the directories it checks and
`packages/{core,scene-graph,vue}/tests` were never added — so the 72
drilled imports in Core's tests, including the ones the round-trip move
just wrote, were never seen.
Core gains `#core-tests/*` beside fig's `#fig-tests/*`, registered with
the architecture rules, and its tests reach their helpers through it
and their source through `#core/*`. The three test directories join
`lint:structure`, which also surfaced six errors they had never been
checked for: four duplicated imports, an empty `noop`, and a
self-assignment the test meant, now written through a named binding.
Both guides state the rule, since a lint nobody can find in prose is
how this went unnoticed.
* fix(tools): point the heavy unit patterns at the relocated round-trip tests
`HEAVY_UNIT_TEST_PATTERNS` still listed the three heavy round-trip
tests under `tests/engine`. `test:unit` discovers them by directory so
the move looked clean, but `--heavy-only` selects by path and silently
stopped choosing them: 8 files, 52 tests, where it now runs 11 and 80.
94 lines
3.3 KiB
TypeScript
94 lines
3.3 KiB
TypeScript
import { expect, test } from 'bun:test'
|
|
|
|
import { resolveWorkspaceRoot } from '@open-pencil/package-artifacts-tools'
|
|
|
|
import {
|
|
isHeavyUnitTest,
|
|
listHeavyUnitTests,
|
|
listUnitTests,
|
|
pathsForUnitTestGroup,
|
|
unitTestGroupNames
|
|
} from '../src/shards'
|
|
|
|
const REPO_ROOT = await resolveWorkspaceRoot(import.meta.dir)
|
|
|
|
async function discover(pattern: string): Promise<string[]> {
|
|
return Array.fromAsync(new Bun.Glob(pattern).scan({ cwd: REPO_ROOT }))
|
|
}
|
|
|
|
test('every app, engine and package-local test belongs to exactly one shard', async () => {
|
|
const discovered = [
|
|
...(await discover('tests/app/**/*.test.ts')),
|
|
...(await discover('tests/integration/**/*.test.ts')),
|
|
...(await discover('tests/engine/**/*.test.ts')),
|
|
...(await discover('packages/*/tests/**/*.test.ts'))
|
|
].filter((file) => !file.startsWith('packages/harness/'))
|
|
const paths = pathsForUnitTestGroup('all')
|
|
const invalidAssignments = discovered.flatMap((file) => {
|
|
const owners = paths.filter((path) => file.startsWith(`${path}/`))
|
|
return owners.length === 1 ? [] : [{ file, owners }]
|
|
})
|
|
|
|
expect(discovered.length).toBeGreaterThan(0)
|
|
expect(invalidAssignments).toEqual([])
|
|
expect((await listUnitTests('all', { includeHeavy: true })).sort()).toEqual(discovered.sort())
|
|
})
|
|
|
|
test('canonical destinations are registered before they hold files', async () => {
|
|
const paths = pathsForUnitTestGroup('all')
|
|
expect(paths).toContain('tests/app')
|
|
expect(paths).toContain('tests/integration')
|
|
for (const owner of [
|
|
'core',
|
|
'scene-graph',
|
|
'vue',
|
|
'fig',
|
|
'kiwi',
|
|
'dom-css',
|
|
'design-jsx',
|
|
'pen',
|
|
'cli',
|
|
'mcp'
|
|
]) {
|
|
expect(paths).toContain(`packages/${owner}/tests`)
|
|
}
|
|
await expect(listUnitTests('all')).resolves.toBeArray()
|
|
})
|
|
|
|
test('quick and explicit heavy tests partition the full engine suite', async () => {
|
|
const quick = await listUnitTests('all')
|
|
const heavy = await listHeavyUnitTests()
|
|
const all = await listUnitTests('all', { includeHeavy: true })
|
|
|
|
expect(quick.filter((file) => heavy.includes(file))).toEqual([])
|
|
expect([...quick, ...heavy].sort()).toEqual(all)
|
|
})
|
|
|
|
test('unit test groups cover all declared shards', () => {
|
|
expect(unitTestGroupNames()).toContain('all')
|
|
expect(pathsForUnitTestGroup('dom')).toContain('tests/engine/dom-css')
|
|
expect(pathsForUnitTestGroup('fig')).toContain('packages/fig/tests')
|
|
expect(pathsForUnitTestGroup('all')).toContain('tests/engine/io')
|
|
})
|
|
|
|
test('heavy unit test matcher excludes fixture-heavy tests', () => {
|
|
expect(isHeavyUnitTest('tests/engine/io/fig/heavy/fixtures.test.ts')).toBe(true)
|
|
expect(isHeavyUnitTest('packages/core/tests/io/formats/fig/roundtrip/glyph-blob.test.ts')).toBe(
|
|
true
|
|
)
|
|
expect(isHeavyUnitTest('tests/engine/dom-css/runtime.test.ts')).toBe(false)
|
|
})
|
|
|
|
test('quick unit test listing excludes heavy tests', async () => {
|
|
const quickFiles = await listUnitTests('all')
|
|
expect(quickFiles).toContain('tests/engine/dom-css/runtime.test.ts')
|
|
expect(quickFiles).not.toContain('tests/engine/io/fig/heavy/fixtures.test.ts')
|
|
expect(quickFiles).not.toContain('tests/engine/io/fig/roundtrip/glyph-blob.test.ts')
|
|
})
|
|
|
|
test('heavy unit test listing contains only heavy tests', async () => {
|
|
const heavyFiles = await listHeavyUnitTests()
|
|
expect(heavyFiles).toContain('tests/engine/io/fig/heavy/fixtures.test.ts')
|
|
expect(heavyFiles.every(isHeavyUnitTest)).toBe(true)
|
|
})
|