84 lines
2.4 KiB
TypeScript
84 lines
2.4 KiB
TypeScript
/**
|
|
* print-bigscreen.test.ts — print + bigscreen 父命令烟囱测试
|
|
*/
|
|
import { describe, it, expect } from 'vitest'
|
|
import { execFileSync } from 'node:child_process'
|
|
import { resolve } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const __dirname = fileURLToPath(new URL('.', import.meta.url))
|
|
const CLI = resolve(__dirname, '../../src/cli.ts')
|
|
|
|
function run(args: string[]): string {
|
|
try {
|
|
return execFileSync('npx', ['tsx', CLI, ...args], {
|
|
encoding: 'utf-8',
|
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
timeout: 30_000,
|
|
})
|
|
} catch (e) {
|
|
const err = e as { stdout?: Buffer | string; status?: number }
|
|
return (err.stdout?.toString() || '')
|
|
}
|
|
}
|
|
|
|
describe('print command tree (W9-D3)', () => {
|
|
it('print --help 列出 3 个子命令', () => {
|
|
const out = run(['print', '--help'])
|
|
expect(out).toContain('list')
|
|
expect(out).toContain('info')
|
|
expect(out).toContain('create')
|
|
})
|
|
|
|
it('print list --ai-help 含 API 路径', () => {
|
|
const out = run(['print', 'list', '--ai-help'])
|
|
expect(out).toContain('/api/system/printDev')
|
|
})
|
|
|
|
it('print info --help 包含 --id', () => {
|
|
const out = run(['print', 'info', '--help'])
|
|
expect(out).toContain('--id')
|
|
})
|
|
|
|
it('print create --ai-help 提示决策 6', () => {
|
|
const out = run(['print', 'create', '--ai-help'])
|
|
expect(out).toContain('决策 6')
|
|
expect(out).toContain('printDev')
|
|
})
|
|
|
|
it('顶层 --help 包含 print', () => {
|
|
const out = run(['--help'])
|
|
expect(out).toContain('print')
|
|
})
|
|
})
|
|
|
|
describe('bigscreen command tree (W9-D2)', () => {
|
|
it('bigscreen --help 列出 4 个子命令', () => {
|
|
const out = run(['bigscreen', '--help'])
|
|
expect(out).toContain('list')
|
|
expect(out).toContain('info')
|
|
expect(out).toContain('create')
|
|
expect(out).toContain('release')
|
|
})
|
|
|
|
it('bigscreen list --ai-help 含 API 路径', () => {
|
|
const out = run(['bigscreen', 'list', '--ai-help'])
|
|
expect(out).toContain('/api/extend/BigData')
|
|
})
|
|
|
|
it('bigscreen info --help 提示无 /{id} 端点', () => {
|
|
const out = run(['bigscreen', 'info', '--help'])
|
|
expect(out).toContain('JNPF 大屏无 /{id} 端点')
|
|
})
|
|
|
|
it('bigscreen create --ai-help 提示决策 6', () => {
|
|
const out = run(['bigscreen', 'create', '--ai-help'])
|
|
expect(out).toContain('决策 6')
|
|
})
|
|
|
|
it('顶层 --help 包含 bigscreen', () => {
|
|
const out = run(['--help'])
|
|
expect(out).toContain('bigscreen')
|
|
})
|
|
})
|