@cancel-worktree-cleanup
Feature: Plan cancel cleans up worktree sandbox (#9230)
  Verifies that cancelling a plan after execute removes the
  git worktree branch and directory to prevent resource leaks.

  Scenario: _cleanup_sandbox_for_plan removes worktree for cancelled plan for cwc
    Given a temp git project with a worktree sandbox for plan "01TESTCANCEL000000000000" for cwc
    And a mocked service that resolves the project for cwc
    When I call _cleanup_sandbox_for_plan for plan "01TESTCANCEL000000000000" for cwc
    Then the branch "cleveragents/plan-01TESTCANCEL000000000000" should not exist for cwc
    And the worktree directory should not exist for cwc

  Scenario: _cleanup_sandbox_for_plan is a no-op when no sandbox exists for cwc
    Given a temp git project without any worktree for cwc
    And a mocked service with no linked resources for cwc
    When I call _cleanup_sandbox_for_plan for plan "01TESTNOSANDBOX0000000000" for cwc
    Then the call should complete without error for cwc
