|
| 1 | +/** |
| 2 | + * @file E2E tests for `socket audit-log`, `socket fix`, and `socket ci`. |
| 3 | + * Ported from the corresponding sections of `packages/cli/test/smoke.sh`. |
| 4 | + * |
| 5 | + * These commands share a shape (help / dry-run / no-args run); audit-log |
| 6 | + * needs auth, fix and ci are local-only. |
| 7 | + * |
| 8 | + * Gated on `RUN_E2E_TESTS=1`. |
| 9 | + */ |
| 10 | + |
| 11 | +import { describe, expect, it } from 'vitest' |
| 12 | + |
| 13 | +import { ENV } from '../../src/constants/env.mts' |
| 14 | +import { |
| 15 | + executeCliCommand, |
| 16 | + executeCliInScratch, |
| 17 | +} from '../helpers/cli-execution.mts' |
| 18 | + |
| 19 | +const RUN = ENV.RUN_E2E_TESTS |
| 20 | + |
| 21 | +describe('socket audit-log (e2e, auth required)', () => { |
| 22 | + it.skipIf(!RUN)('audit-log --help exits 0', async () => { |
| 23 | + const result = await executeCliCommand(['audit-log', '--help']) |
| 24 | + expect(result.code).toBe(0) |
| 25 | + }) |
| 26 | + |
| 27 | + it.skipIf(!RUN)('audit-log --dry-run exits 0', async () => { |
| 28 | + const result = await executeCliCommand(['audit-log', '--dry-run']) |
| 29 | + expect(result.code).toBe(0) |
| 30 | + }) |
| 31 | + |
| 32 | + it.skipIf(!RUN)('audit-log exits 0', async () => { |
| 33 | + const result = await executeCliCommand(['audit-log']) |
| 34 | + expect(result.code).toBe(0) |
| 35 | + }) |
| 36 | +}) |
| 37 | + |
| 38 | +describe('socket fix (e2e)', () => { |
| 39 | + it.skipIf(!RUN)('fix --help exits 0', async () => { |
| 40 | + const result = await executeCliCommand(['fix', '--help']) |
| 41 | + expect(result.code).toBe(0) |
| 42 | + }) |
| 43 | + |
| 44 | + it.skipIf(!RUN)('fix --dry-run exits 0', async () => { |
| 45 | + const result = await executeCliCommand(['fix', '--dry-run']) |
| 46 | + expect(result.code).toBe(0) |
| 47 | + }) |
| 48 | + |
| 49 | + it.skipIf(!RUN)('fix exits 0', async () => { |
| 50 | + // Scratch-isolated with a minimal package.json so `fix` has something |
| 51 | + // to operate on without touching the developer's repo. |
| 52 | + const result = await executeCliInScratch(['fix'], { |
| 53 | + seedFiles: { |
| 54 | + 'package.json': JSON.stringify({ name: 'socket-cli-e2e-fix', version: '0.0.0' }), |
| 55 | + }, |
| 56 | + }) |
| 57 | + expect(result.code).toBe(0) |
| 58 | + }) |
| 59 | +}) |
| 60 | + |
| 61 | +describe('socket ci (e2e)', () => { |
| 62 | + it.skipIf(!RUN)('ci --help exits 0', async () => { |
| 63 | + const result = await executeCliCommand(['ci', '--help']) |
| 64 | + expect(result.code).toBe(0) |
| 65 | + }) |
| 66 | + |
| 67 | + it.skipIf(!RUN)('ci --dry-run exits 0', async () => { |
| 68 | + const result = await executeCliCommand(['ci', '--dry-run']) |
| 69 | + expect(result.code).toBe(0) |
| 70 | + }) |
| 71 | + |
| 72 | + it.skipIf(!RUN)('ci exits 0', async () => { |
| 73 | + const result = await executeCliInScratch(['ci'], { |
| 74 | + seedFiles: { |
| 75 | + 'package.json': JSON.stringify({ name: 'socket-cli-e2e-ci', version: '0.0.0' }), |
| 76 | + }, |
| 77 | + }) |
| 78 | + expect(result.code).toBe(0) |
| 79 | + }) |
| 80 | +}) |
0 commit comments