61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
/**
|
|
* report.test.ts — report 父命令烟囱测试
|
|
*/
|
|
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('report command tree (W8-D2)', () => {
|
|
it('report --help 列出 3 个子命令 (JNPF 报表只读)', () => {
|
|
const out = run(['report', '--help'])
|
|
expect(out).toContain('list')
|
|
expect(out).toContain('info')
|
|
expect(out).toContain('templates')
|
|
})
|
|
|
|
it('report list --help 描述正确', () => {
|
|
const out = run(['report', 'list', '--help'])
|
|
expect(out).toContain('只读模板')
|
|
})
|
|
|
|
it('report list --ai-help 输出 markdown 提示决策 6', () => {
|
|
const out = run(['report', 'list', '--ai-help'])
|
|
expect(out).toContain('决策 6')
|
|
expect(out).toContain('ReportManage')
|
|
})
|
|
|
|
it('report templates --help 列出 5 个模板', () => {
|
|
const out = run(['report', 'templates', '--help'])
|
|
expect(out).toContain('Month')
|
|
expect(out).toContain('Quarter')
|
|
expect(out).toContain('Purchase')
|
|
})
|
|
|
|
it('report info --help 包含 --id', () => {
|
|
const out = run(['report', 'info', '--help'])
|
|
expect(out).toContain('--id')
|
|
})
|
|
|
|
it('顶层 --help 包含 report', () => {
|
|
const out = run(['--help'])
|
|
expect(out).toContain('report')
|
|
})
|
|
})
|