---
phase: 16-flag-translation
plan: 02
type: execute
wave: 2
depends_on: ["16-01"]
files_modified:
  - tests/test_clean.py
  - tests/test_config.py
  - tests/test_switch.py
  - tests/conftest.py
  - pyproject.toml
autonomous: true
user_setup: []

must_haves:
  truths:
    - "CLEAN-01 validated: git clean -f removes untracked files"
    - "CLEAN-02 validated: git clean -fd removes untracked directories"
    - "CLEAN-03 validated: git clean -n shows files without removing"
    - "CONFIG-01 validated: git config <key> reads values"
    - "CONFIG-02 validated: git config <key> <value> sets values"
    - "CONFIG-03 validated: git config --list shows all config"
    - "SWITCH-01 validated: git switch <branch> switches to bookmark"
    - "SWITCH-02 validated: git switch -c <name> creates bookmark"
  artifacts:
    - path: "tests/test_clean.py"
      provides: "E2E tests for clean command"
      contains: "class TestClean"
    - path: "tests/test_config.py"
      provides: "E2E tests for config command"
      contains: "class TestConfig"
    - path: "tests/test_switch.py"
      provides: "E2E tests for switch command"
      contains: "class TestSwitch"
  key_links:
    - from: "tests/test_clean.py"
      to: "conftest.run_gitsl"
      via: "import and call"
      pattern: "from conftest import run_gitsl"
    - from: "tests/test_clean.py"
      to: "sl_repo_with_commit fixture"
      via: "pytest fixture dependency"
      pattern: "def test_.*sl_repo_with_commit"
---

<objective>
Create E2E tests validating all 8 Phase 16 requirements for clean, config, and switch commands.

Purpose: Validate that flag translation works correctly for all documented requirements (CLEAN-01 through SWITCH-02).

Output: 3 new test files + pytest marker registration
</objective>

<execution_context>
@~/.claude/get-shit-done/workflows/execute-plan.md
@~/.claude/get-shit-done/templates/summary.md
</execution_context>

<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md
@.planning/phases/16-flag-translation/16-RESEARCH.md
@.planning/phases/16-flag-translation/16-01-SUMMARY.md
@tests/test_rm.py (example test structure)
@tests/conftest.py (fixtures: sl_repo, sl_repo_with_commit)
</context>

<tasks>

<task type="auto">
  <name>Task 1: Create E2E tests for clean, config, switch commands</name>
  <files>tests/test_clean.py, tests/test_config.py, tests/test_switch.py</files>
  <action>
Create three test files following the established test pattern from Phase 15. Use the test code examples from 16-RESEARCH.md as templates.

**tests/test_clean.py:**
- pytestmark with pytest.mark.clean
- TestCleanForce (CLEAN-01): test_clean_removes_untracked, test_clean_requires_force (exit 128)
- TestCleanForceDir (CLEAN-02): test_clean_removes_untracked_dir
- TestCleanDryRun (CLEAN-03): test_clean_dry_run_shows_files (file still exists after -n)

**tests/test_config.py:**
- pytestmark with pytest.mark.config
- TestConfigRead (CONFIG-01): test_config_read_value
- TestConfigWrite (CONFIG-02): test_config_write_value
- TestConfigList (CONFIG-03): test_config_list

**tests/test_switch.py:**
- pytestmark with pytest.mark.switch
- TestSwitchBranch (SWITCH-01): test_switch_to_bookmark
- TestSwitchCreate (SWITCH-02): test_switch_create_bookmark

All tests should:
- Use sl_repo or sl_repo_with_commit fixtures
- Import run_gitsl from conftest
- Import run_command from helpers.commands for setup/verification
- Include sl_available check and skipif marker
  </action>
  <verify>
```bash
python3 -m py_compile tests/test_clean.py tests/test_config.py tests/test_switch.py
pytest tests/test_clean.py tests/test_config.py tests/test_switch.py --collect-only
```
  </verify>
  <done>
- test_clean.py has 4 tests covering CLEAN-01, CLEAN-02, CLEAN-03 + safety rejection
- test_config.py has 3 tests covering CONFIG-01, CONFIG-02, CONFIG-03
- test_switch.py has 2 tests covering SWITCH-01, SWITCH-02
- All tests collected successfully
  </done>
</task>

<task type="auto">
  <name>Task 2: Register pytest markers for Phase 16 commands</name>
  <files>pyproject.toml</files>
  <action>
Add pytest markers for the new command test categories in pyproject.toml under [tool.pytest.ini_options].

Add these markers to the existing markers list:
```toml
"clean: Tests for git clean command",
"config: Tests for git config command",
"switch: Tests for git switch command",
```

This follows the Phase 15 pattern where each command gets its own marker for targeted test runs.
  </action>
  <verify>
```bash
pytest --markers | grep -E "(clean|config|switch)"
```
  </verify>
  <done>
- pyproject.toml has clean, config, switch markers registered
- pytest --markers shows all three new markers
  </done>
</task>

<task type="auto">
  <name>Task 3: Run full test suite and verify all tests pass</name>
  <files>(none - verification only)</files>
  <action>
Run the complete test suite to verify:
1. All new Phase 16 tests pass
2. No regressions in existing tests

```bash
pytest tests/ -v --tb=short
```

If any tests fail, investigate and fix the issue in the relevant handler (cmd_clean.py, cmd_config.py, cmd_switch.py) or test file.
  </action>
  <verify>
```bash
pytest tests/test_clean.py tests/test_config.py tests/test_switch.py -v
pytest tests/ --tb=short  # Full suite regression check
```
  </verify>
  <done>
- All 9 new tests pass (4 clean + 3 config + 2 switch)
- Full test suite passes with no regressions
- Requirements CLEAN-01 through SWITCH-02 validated
  </done>
</task>

</tasks>

<verification>
Overall phase verification:

1. Run Phase 16 specific tests:
```bash
pytest tests/test_clean.py tests/test_config.py tests/test_switch.py -v
```

2. Verify requirement coverage:
- CLEAN-01: TestCleanForce.test_clean_removes_untracked
- CLEAN-02: TestCleanForceDir.test_clean_removes_untracked_dir
- CLEAN-03: TestCleanDryRun.test_clean_dry_run_shows_files
- CONFIG-01: TestConfigRead.test_config_read_value
- CONFIG-02: TestConfigWrite.test_config_write_value
- CONFIG-03: TestConfigList.test_config_list
- SWITCH-01: TestSwitchBranch.test_switch_to_bookmark
- SWITCH-02: TestSwitchCreate.test_switch_create_bookmark

3. Safety test (critical):
- TestCleanForce.test_clean_requires_force must verify exit code 128
</verification>

<success_criteria>
- [ ] test_clean.py exists with 4 tests
- [ ] test_config.py exists with 3 tests
- [ ] test_switch.py exists with 2 tests
- [ ] pytest markers registered (clean, config, switch)
- [ ] All 9 new tests pass
- [ ] Full test suite passes (no regressions)
- [ ] Safety test confirms exit 128 without -f/-n
</success_criteria>

<output>
After completion, create `.planning/phases/16-flag-translation/16-02-SUMMARY.md`
</output>
