Skip to content

test(cli): add Copilot CLI subprocess integration tests for SQUAD_TEAM_ROOT - #838

Merged
tamirdresher merged 2 commits into
devfrom
squad/836-subprocess-integration-tests
Apr 5, 2026
Merged

tamirdresher merged 2 commits into
devfrom
squad/836-subprocess-integration-tests

Conversation

@diberry

@diberry diberry commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds 8 integration tests in est/cli/team-root-resolution.test.ts verifying SQUAD_TEAM_ROOT env-var resolution across all scenarios:

Tests added

getSquadStartDir() env-var handling (3 tests)

  • Returns SQUAD_TEAM_ROOT when env var is set
  • Falls back to process.cwd() when unset
  • Falls back to process.cwd() when empty string

resolveSquad() integration (3 tests)

  • Finds .squad/ when SQUAD_TEAM_ROOT points to a valid project
  • Finds .squad/ even when cwd is elsewhere (Copilot CLI bang-command scenario)
  • Returns null when SQUAD_TEAM_ROOT is unset and cwd has no .squad/

Invalid SQUAD_TEAM_ROOT path (2 tests)

  • Returns null for a non-existent path
  • Returns null for a dir without .squad/

Context

PR #763 added \getSquadStartDir()\ + 2 tests in
ap-subprocess.test.ts, but there were no tests verifying SQUAD_TEAM_ROOT works across all resolution scenarios, and no tests simulating the Copilot CLI bang-command subprocess scenario where cwd differs from the interactive shell.

Test-only PR — no product code changes.

Closes #836
Related: PR #763, #835

Copilot AI review requested due to automatic review settings April 4, 2026 23:26
@github-actions

github-actions Bot commented Apr 4, 2026 •

Copy link
Copy Markdown
Contributor

🛫 PR Readiness Check

ℹ️ This comment updates on each push. Last checked: commit 45f7d9e

⚠️ 4 item(s) to address before review

Status Check Details
❌ Single commit 2 commits — consider squashing before review
✅ Not in draft Ready for review
✅ Branch up to date Up to date with dev
❌ Copilot review No Copilot review yet — it may still be processing
✅ Changeset present Changeset file found
✅ Scope clean No .squad/ or docs/proposals/ files
✅ No merge conflicts No merge conflicts
❌ Copilot threads resolved 1 unresolved Copilot thread(s) — fix and resolve before merging
❌ CI passing 12 check(s) still running

This check runs automatically on every push. Fix any ❌ items and push again.
See CONTRIBUTING.md and PR Requirements for details.

@github-actions

github-actions Bot commented Apr 4, 2026 •

Copy link
Copy Markdown
Contributor

🟡 Impact Analysis — PR #838

Risk tier: 🟡 MEDIUM

📊 Summary

Metric Count
Files changed 2
Files added 2
Files modified 0
Files deleted 0
Modules touched 2

🎯 Risk Factors

  • 2 files changed (≤5 → LOW)
  • 2 modules touched (2-4 → MEDIUM)

📦 Modules Affected

root (1 file)
  • .changeset/subprocess-integration-tests.md
tests (1 file)
  • test/cli/team-root-resolution.test.ts

This report is generated automatically for every PR. See #733 for details.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an integration-style Vitest suite to validate SQUAD_TEAM_ROOT start-directory behavior (including the Copilot CLI bang-command “cwd differs” scenario) by exercising getSquadStartDir()-equivalent logic and resolveSquad() results.

Changes:

  • Adds coverage for SQUAD_TEAM_ROOT set / unset / empty-string behavior.
  • Adds resolveSquad() scenarios for valid team roots, mismatched cwd, and invalid/non-existent roots.

Comment on lines +181 to +183
const fakePath = join(tmpdir(), 'squad-nonexistent-' + Date.now());
process.env['SQUAD_TEAM_ROOT'] = fakePath;

Copilot AI Apr 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test assumes fakePath does not exist, but join(tmpdir(), 'squad-nonexistent-' + Date.now()) can collide with an existing directory/file (e.g., leftover from a prior run), making the test flaky. Consider generating a guaranteed-nonexistent path (e.g., create a temp dir with mkdtempSync and immediately remove it, or append a random suffix and expect(existsSync(fakePath)).toBe(false) before calling resolveSquad).

Copilot uses AI. Check for mistakes.
Verifies getSquadStartDir() across all resolution scenarios:
env var set, unset, empty, invalid path.

Closes #836
Related: PR #763, #835

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@diberry
diberry force-pushed the squad/836-subprocess-integration-tests branch from 3610dbc to 9afef5c Compare April 4, 2026 23:41

@tamirdresher tamirdresher left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — Solid integration tests for SQUAD_TEAM_ROOT resolution. Proper temp dir setup/teardown.

@tamirdresher
tamirdresher merged commit d38a340 into dev Apr 5, 2026
18 checks passed
@tamirdresher
tamirdresher deleted the squad/836-subprocess-integration-tests branch April 5, 2026 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(cli): add Copilot CLI subprocess integration tests for SQUAD_TEAM_ROOT

3 participants