feat(domain): equine legacy importer (packages/anatomy) + generated official equine sheet seed as draft
This commit is contained in:
1 parent
f4682cdba5
commit
52bfc11553
43 files changed
+18466
-33
No files matched your search
@@ -0,0 +1,49 @@
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import { join } from 'node:path'
|
||||
import {
|
||||
EQUINE_SEED_DIR,
|
||||
EQUINE_SOURCE_PATHS,
|
||||
SEED_SQL_FILE,
|
||||
renderArtifacts,
|
||||
sha256Hex,
|
||||
type AssetRecord,
|
||||
} from '../src'
|
||||
import { REPO_ROOT, runImport } from './helpers'
|
||||
|
||||
const seedDir = join(REPO_ROOT, EQUINE_SEED_DIR)
|
||||
let artifacts: Record<string, string>
|
||||
|
||||
beforeAll(async () => {
|
||||
artifacts = await renderArtifacts(await runImport())
|
||||
})
|
||||
|
||||
describe('committed equine seed (golden)', () => {
|
||||
it.each([
|
||||
'document.json',
|
||||
'legacy-id-map.json',
|
||||
'assets.json',
|
||||
SEED_SQL_FILE,
|
||||
'IMPORT-REPORT.md',
|
||||
])('%s equals a fresh run (rerun pnpm import:equine)', async (file) => {
|
||||
const committed = await readFile(join(seedDir, file), 'utf8')
|
||||
expect(committed).toBe(artifacts[file])
|
||||
})
|
||||
|
||||
it('copies the SVG assets byte for byte with the recorded sha256', async () => {
|
||||
const assets = JSON.parse(artifacts['assets.json']!) as AssetRecord[]
|
||||
const sources = [EQUINE_SOURCE_PATHS.mainSvg, EQUINE_SOURCE_PATHS.headSvg]
|
||||
for (const [index, asset] of assets.entries()) {
|
||||
const copy = await readFile(join(seedDir, 'assets', asset.file))
|
||||
const original = await readFile(join(REPO_ROOT, sources[index]!))
|
||||
expect(copy.equals(original)).toBe(true)
|
||||
expect(sha256Hex(copy)).toBe(asset.sha256)
|
||||
expect(copy.byteLength).toBe(asset.byte_size)
|
||||
}
|
||||
})
|
||||
|
||||
it('seeds a draft and never publishes', () => {
|
||||
const sql = artifacts[SEED_SQL_FILE]!
|
||||
expect(sql).toContain('private.insert_sheet_draft')
|
||||
expect(sql).not.toContain('publish_sheet_version')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user