Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/acceptance/features/hostile-pipe-mode.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Feature: Hostile — Non-TTY pipe mode

Scenario: Status works when piped (non-TTY)
Given a non-TTY environment
And the current directory has a ".squad" directory
When I run "squad status" in non-TTY mode
Then the output contains "Squad Status"
And the exit code is 0
Expand Down
2 changes: 2 additions & 0 deletions test/acceptance/features/hostile-tiny-terminal.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ Feature: Hostile — Tiny terminal (40x10)

Scenario: Status command works at 40x10
Given a terminal size of 40 columns by 10 rows
And the current directory has a ".squad" directory
When I run "squad status" with that terminal size
Then the output contains "Squad Status"
And the exit code is 0

Scenario: Doctor command works at 40x10
Given a terminal size of 40 columns by 10 rows
And the current directory has a ".squad" directory
When I run "squad doctor" with that terminal size
Then the exit code is 0

Expand Down
5 changes: 3 additions & 2 deletions test/acceptance/hostile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { afterEach } from 'vitest';
import { join } from 'node:path';
import { createRegistry, runFeature } from './support/runner.js';
import { registerCLISteps } from './steps/cli-steps.js';
import { cleanupAcceptanceTempDirs, registerCLISteps } from './steps/cli-steps.js';
import { registerHostileSteps } from './steps/hostile-steps.js';
import { TerminalHarness } from './harness.js';

Expand All @@ -16,7 +16,7 @@ const registry = createRegistry();
registerHostileSteps(registry);
registerCLISteps(registry);

// Cleanup harnesses after each test
// Cleanup harnesses and temp dirs after each test
afterEach(async (context) => {
const harness = (context as Record<string, unknown>).harness as TerminalHarness | undefined;
if (harness) {
Expand All @@ -26,6 +26,7 @@ afterEach(async (context) => {
if (rapidHarnesses) {
await Promise.all(rapidHarnesses.map(h => h.close()));
}
cleanupAcceptanceTempDirs();
});

const featuresDir = join(__dirname, 'features');
Expand Down
2 changes: 1 addition & 1 deletion test/acceptance/steps/cli-steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function registerCLISteps(registry: StepDefinitions): void {
// #2015 isolation). Mirrors the sibling "without a .squad directory"
// step's use of an isolated temp dir, and downstream "I run" steps pick
// up context.tempDir automatically.
const tempDir = mkdtempSync(join(tmpdir(), 'squad-e2e-'));
const tempDir = makeTempDir();
// consult/check commands gate on "is this a git repo" before the
// .squad check, so the sandbox must actually be a git repo (same
// convention as test/cli/consult.test.ts, test/sdk/consult.test.ts).
Expand Down
7 changes: 5 additions & 2 deletions test/acceptance/steps/hostile-steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ export function registerHostileSteps(registry: StepDefinitions): void {
const args = command.replace(/^squad\s*/, '').split(/\s+/).filter(Boolean);
const cols = context.terminalCols as number;
const rows = context.terminalRows as number;
const cwd = context.tempDir as string | undefined;

const harness = await TerminalHarness.spawnWithArgs(args, { cols, rows });
try { await harness.waitForExit(5000); } catch { /* timeout ok */ }
const harness = await TerminalHarness.spawnWithArgs(args, { cols, rows, cwd });
try { await harness.waitForExit(15000); } catch { /* timeout ok */ }
context.harness = harness;
context.output = harness.getOutput();
context.exitCode = harness.getExitCode();
Expand All @@ -111,9 +112,11 @@ export function registerHostileSteps(registry: StepDefinitions): void {
if (!match) throw new Error('Pattern match failed');
const command = match[1];
const args = command.replace(/^squad\s*/, '').split(/\s+/).filter(Boolean);
const cwd = context.tempDir as string | undefined;

// Force non-TTY via env
const harness = await TerminalHarness.spawnWithArgs(args, {
cwd,
env: { TERM: 'dumb', NO_COLOR: '1', FORCE_COLOR: '0' }
});
try { await harness.waitForExit(5000); } catch { /* timeout ok */ }
Expand Down
15 changes: 13 additions & 2 deletions test/ux-gates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,24 @@
*/

import { describe, it, expect, afterEach } from 'vitest';
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { TerminalHarness } from './acceptance/harness.js';

describe('UX Gates', () => {
let harness: TerminalHarness | null = null;
let projectDir: string | null = null;

afterEach(async () => {
if (harness) {
await harness.close();
harness = null;
}
if (projectDir) {
rmSync(projectDir, { recursive: true, force: true });
projectDir = null;
}
});

it('No overflow beyond terminal width (80 chars)', async () => {
Expand Down Expand Up @@ -64,8 +72,11 @@ describe('UX Gates', () => {
});

it('Status command shows clear output structure', async () => {
harness = await TerminalHarness.spawnWithArgs(['status']);
await harness.waitForExit(5000);
projectDir = mkdtempSync(join(tmpdir(), 'squad-ux-gates-'));
mkdirSync(join(projectDir, '.squad'));
writeFileSync(join(projectDir, '.squad', 'team.md'), '# UX test team\n');
harness = await TerminalHarness.spawnWithArgs(['status'], { cwd: projectDir });
expect(await harness.waitForExit(5000)).toBe(0);

const output = harness.captureFrame();

Expand Down
Loading