2026-08-06 04:40:11 +08:00
|
|
|
/**
|
2026-08-06 17:28:30 +08:00
|
|
|
* The bundle's substance is its patch file: the `dsh.bundle.patch` manifest
|
|
|
|
|
* field must name a real, parseable patch list.
|
2026-08-06 04:40:11 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { readFileSync } from 'node:fs'
|
2026-08-06 09:53:49 +08:00
|
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
|
import { resolve } from 'node:path'
|
2026-08-06 04:40:11 +08:00
|
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
|
import * as yaml from 'js-yaml'
|
|
|
|
|
import { entryListSchema } from '@cordisjs/plugin-include'
|
|
|
|
|
|
|
|
|
|
describe('dsh-base bundle', () => {
|
2026-08-06 17:28:30 +08:00
|
|
|
it('declares a parseable patch list through the dsh.bundle.patch manifest field', () => {
|
2026-08-06 09:53:49 +08:00
|
|
|
const root = fileURLToPath(new URL('..', import.meta.url))
|
2026-08-06 17:28:30 +08:00
|
|
|
const manifest = JSON.parse(readFileSync(resolve(root, 'package.json'), 'utf8')) as { dsh?: { bundle?: { patch?: string } } }
|
|
|
|
|
expect(manifest.dsh?.bundle?.patch).toBe('./cordis.patch.yml')
|
|
|
|
|
const parsed = yaml.load(readFileSync(resolve(root, manifest.dsh!.bundle!.patch!), 'utf8'), { schema: entryListSchema })
|
2026-08-06 04:40:11 +08:00
|
|
|
expect(Array.isArray(parsed)).toBe(true)
|
|
|
|
|
// The base layer is one insert list over the empty profile root.
|
|
|
|
|
const rows = (parsed as { insert?: { id?: string }[] }[]).flatMap(patch => patch.insert ?? [])
|
|
|
|
|
expect(rows.length).toBeGreaterThan(50)
|
|
|
|
|
expect(rows.some(row => row.id === 'agent-loop')).toBe(true)
|
|
|
|
|
})
|
|
|
|
|
})
|