|
| 1 | +import {assert} from 'chai' |
| 2 | +import {execSync} from 'child_process' |
| 3 | +import * as path from 'path' |
| 4 | +import {isNodeosAvailable} from '../utils/test-helpers' |
| 5 | + |
| 6 | +/** |
| 7 | + * E2E tests for CLI command structure: |
| 8 | + * - Verifies commands exist and have correct help text |
| 9 | + * - Tests command hierarchy |
| 10 | + * |
| 11 | + * Note: These tests don't require a running chain, but we still |
| 12 | + * check for nodeos availability to match other E2E test behavior. |
| 13 | + */ |
| 14 | +suite('E2E: CLI Structure', () => { |
| 15 | + const cliPath = path.join(__dirname, '../../lib/cli.js') |
| 16 | + |
| 17 | + suiteSetup(function () { |
| 18 | + if (!isNodeosAvailable()) { |
| 19 | + // eslint-disable-next-line no-console |
| 20 | + console.log('Skipping E2E tests: nodeos is not available in PATH') |
| 21 | + this.skip() |
| 22 | + } |
| 23 | + }) |
| 24 | + |
| 25 | + suite('Command Structure', () => { |
| 26 | + test('wallet command has correct subcommands', function () { |
| 27 | + const output = execSync(`node ${cliPath} wallet --help`, {encoding: 'utf8'}) |
| 28 | + |
| 29 | + assert.include(output, 'create') |
| 30 | + assert.include(output, 'keys') |
| 31 | + assert.include(output, 'account') |
| 32 | + assert.include(output, 'transact') |
| 33 | + }) |
| 34 | + |
| 35 | + test('wallet account command has create subcommand', function () { |
| 36 | + const output = execSync(`node ${cliPath} wallet account --help`, {encoding: 'utf8'}) |
| 37 | + |
| 38 | + assert.include(output, 'create') |
| 39 | + assert.include(output, 'Create a new account on the blockchain') |
| 40 | + }) |
| 41 | + |
| 42 | + test('contract deploy command works', function () { |
| 43 | + const output = execSync(`node ${cliPath} contract deploy --help`, {encoding: 'utf8'}) |
| 44 | + |
| 45 | + assert.include(output, 'Deploy a compiled contract') |
| 46 | + assert.include(output, '--account') |
| 47 | + assert.include(output, '--url') |
| 48 | + assert.include(output, '--key') |
| 49 | + }) |
| 50 | + |
| 51 | + test('dev command is at top level', function () { |
| 52 | + const output = execSync(`node ${cliPath} dev --help`, {encoding: 'utf8'}) |
| 53 | + |
| 54 | + assert.include(output, 'Start local chain and watch for changes') |
| 55 | + assert.include(output, '--account') |
| 56 | + assert.include(output, '--port') |
| 57 | + assert.include(output, '--clean') |
| 58 | + }) |
| 59 | + |
| 60 | + test('compile command is at top level', function () { |
| 61 | + const output = execSync(`node ${cliPath} compile --help`, {encoding: 'utf8'}) |
| 62 | + |
| 63 | + assert.include(output, 'Compile C++ contract files') |
| 64 | + assert.include(output, '--output') |
| 65 | + }) |
| 66 | + |
| 67 | + test('wallet keys command has add subcommand', function () { |
| 68 | + const output = execSync(`node ${cliPath} wallet keys --help`, {encoding: 'utf8'}) |
| 69 | + |
| 70 | + assert.include(output, 'add') |
| 71 | + assert.include(output, 'create') |
| 72 | + assert.include(output, 'Add an existing private key') |
| 73 | + }) |
| 74 | + }) |
| 75 | +}) |
| 76 | + |
0 commit comments