|
1 | 1 | import assert from 'node:assert/strict'; |
2 | 2 |
|
3 | | -import { describe, test } from 'vitest'; |
| 3 | +import { test } from 'vitest'; |
4 | 4 |
|
5 | | -import { getCommandDefinition, getGroupDefinitions, listCommandGroups, listCommandNames } from '../../src/commands/registry/index.js'; |
6 | 5 | import { parseInvocationForCli } from '../../src/cli/parse.js'; |
7 | 6 | import { runCli } from '../../src/cli/run.js'; |
8 | 7 | import { MemoryStream, createRuntimeDependencies, readPackageVersion } from '../support/cli-test.js'; |
9 | 8 |
|
10 | | -const COMMAND_GROUPS = listCommandGroups(); |
11 | | -const ALL_COMMANDS = listCommandNames(); |
12 | | - |
13 | 9 | test('runCli renders root help', async () => { |
14 | 10 | const stdout = new MemoryStream(); |
15 | 11 | const stderr = new MemoryStream(); |
@@ -101,52 +97,6 @@ test('runCli does not support -v as a root-level alias for --version', async () |
101 | 97 | assert.match(stderr.output, /See: orfe --help/); |
102 | 98 | }); |
103 | 99 |
|
104 | | -describe('runCli renders help for each command group', () => { |
105 | | - for (const group of COMMAND_GROUPS) { |
106 | | - test(`group ${group}`, async () => { |
107 | | - const stdout = new MemoryStream(); |
108 | | - const stderr = new MemoryStream(); |
109 | | - |
110 | | - const exitCode = await runCli([group, '--help'], { stdout, stderr }); |
111 | | - |
112 | | - assert.equal(exitCode, 0); |
113 | | - assert.equal(stderr.output, ''); |
114 | | - assert.match(stdout.output, new RegExp(`orfe ${group}`)); |
115 | | - assert.match(stdout.output, /Usage:/); |
116 | | - assert.match(stdout.output, /Commands:/); |
117 | | - |
118 | | - for (const definition of getGroupDefinitions(group)) { |
119 | | - assert.match(stdout.output, new RegExp(`${definition.leaf} - ${escapeForRegExp(definition.purpose)}`)); |
120 | | - } |
121 | | - }); |
122 | | - } |
123 | | -}); |
124 | | - |
125 | | -describe('runCli renders leaf help for every agreed V1 command', () => { |
126 | | - for (const commandName of ALL_COMMANDS) { |
127 | | - test(commandName, async () => { |
128 | | - const stdout = new MemoryStream(); |
129 | | - const stderr = new MemoryStream(); |
130 | | - const definition = getCommandDefinition(commandName); |
131 | | - const args = definition.topLevel ? [commandName, '--help'] : [definition.group, definition.leaf, '--help']; |
132 | | - |
133 | | - const exitCode = await runCli(args, { stdout, stderr }); |
134 | | - |
135 | | - assert.equal(exitCode, 0); |
136 | | - assert.equal(stderr.output, ''); |
137 | | - assert.match(stdout.output, new RegExp(`^${escapeForRegExp(commandName)}`, 'm')); |
138 | | - assert.match(stdout.output, new RegExp(`Purpose: ${escapeForRegExp(definition.purpose)}`)); |
139 | | - assert.match(stdout.output, new RegExp(`Usage: ${escapeForRegExp(definition.usage)}`)); |
140 | | - assert.match(stdout.output, /Required options:/); |
141 | | - assert.match(stdout.output, /Optional options:/); |
142 | | - assert.match(stdout.output, new RegExp(`Success: ${escapeForRegExp(definition.successSummary)}`)); |
143 | | - assert.match(stdout.output, /Examples:/); |
144 | | - assert.match(stdout.output, /JSON success shape example:/); |
145 | | - assert.match(stdout.output, new RegExp(escapeForRegExp(JSON.stringify(definition.successDataExample)))); |
146 | | - }); |
147 | | - } |
148 | | -}); |
149 | | - |
150 | 100 | test('runCli reports invalid usage for unknown commands', async () => { |
151 | 101 | const stdout = new MemoryStream(); |
152 | 102 | const stderr = new MemoryStream(); |
@@ -232,7 +182,3 @@ test('runCli reports malformed repo overrides as usage errors', async () => { |
232 | 182 | assert.match(stderr.output, /Repository must be in "owner\/name" format\./); |
233 | 183 | assert.match(stderr.output, /See: orfe issue get --help/); |
234 | 184 | }); |
235 | | - |
236 | | -function escapeForRegExp(value: string): string { |
237 | | - return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); |
238 | | -} |
0 commit comments