Files
apes-sidebar/tests/dsh-baseline.spec.ts
T
hairyfbot ea8ee92527 test(baseline): CI 宿主钉版跟随 engines.dsh 到 rc.3
ci.yml 的宿主钉版已由维护者改为 0.2.2-rc.3,dsh-baseline 的 CI 断言从 dev 钉版
常量 baseline 换成运行侧常量 hostBaseline,与 e2e / 安装脚本同一来源。
2026-11-21 12:00:00 +08:00

58 lines
2.9 KiB
TypeScript

/**
* Host baseline contract: package DSH peers/dev pins, standalone installers,
* e2e fallback/version check and CI must move together, without floating CLI tags.
*/
import { readFileSync } from 'node:fs'
import { describe, expect, it } from 'vitest'
const baseline = '0.2.2-rc.2'
/** The host runtime the mount lane and the standalone installers pin. It follows
* `package.json#engines.dsh`, which is stricter than the peer floor: the plugin
* installs on this line or newer, so every place that actually runs it moves. */
const hostBaseline = '0.2.2-rc.3'
const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'))
const bash = readFileSync(new URL('../scripts/install.sh', import.meta.url), 'utf8')
const powershell = readFileSync(new URL('../scripts/install.ps1', import.meta.url), 'utf8')
const e2e = readFileSync(new URL('../scripts/e2e-common.sh', import.meta.url), 'utf8')
const ci = readFileSync(new URL('../.github/workflows/ci.yml', import.meta.url), 'utf8')
describe('DSH host baseline', () => {
it('keeps all DSH package peers and dev pins on the exact baseline', () => {
for (const [section, prefix] of [['peerDependencies', '^'], ['devDependencies', '']] as const) {
const entries = Object.entries(pkg[section]).filter(([name]) => name.startsWith('@deepseek-ai/dsh-'))
expect(entries.length, section).toBeGreaterThan(0)
for (const [name, version] of entries) {
expect(version, `${section}.${name}`).toBe(`${prefix}${baseline}`)
}
}
})
it('does not publish or depend on the retired invariant companion', () => {
expect(pkg.exports).not.toHaveProperty('./invariant')
expect(pkg.files).not.toContain('lib/invariant.js')
for (const section of ['peerDependencies', 'devDependencies', 'dependencies']) {
expect(pkg[section]).not.toHaveProperty('@deepseek-ai/dsh-invariants')
}
})
it('pins both standalone installer npx fallbacks', () => {
expect(bash).toContain(`printf 'npx -y --package @deepseek-ai/dsh@${hostBaseline} dsh'`)
expect(powershell).toContain(`$cliArgs = @('-y', '--package', '@deepseek-ai/dsh@${hostBaseline}', 'dsh', 'plugin'`)
for (const source of [bash, powershell]) {
expect(source).not.toMatch(/^\s*(?:source|\.)\s+[^\r\n]*e2e-common/m)
}
})
it('pins the e2e fallback and expected version to the same baseline', () => {
expect(e2e).toContain('DSH_NPX_SPEC="${DSH_NPX_SPEC:-@deepseek-ai/dsh@' + hostBaseline + '}"')
expect(e2e).toContain('expected="${DSH_EXPECT_VERSION:-' + hostBaseline + '}"')
})
it.each(['\n', '\r\n'])('pins CI with its heap budget and peer resolution intact (%j)', (eol) => {
// Git may check out YAML as CRLF on Windows; the contract is the same.
const source = ci.replace(/\r?\n/g, eol)
expect(source).toContain(`NODE_OPTIONS: --max-old-space-size=4096${eol} run: npm install -g @deepseek-ai/dsh@${hostBaseline}${eol}`)
expect(source).not.toMatch(/^\s*run:.*--legacy-peer-deps/m)
})
})