Private
Public Access
0
0

feat(api_hooks): add /api/project_switch_status endpoint for deterministic test signaling

Adds a new endpoint that exposes the project-switch state machine so tests
can poll for completion instead of guessing with timeouts.

- AppController: track _project_switch_error on failure paths
- src/api_hooks.py: GET /api/project_switch_status returns
  {in_progress, pending_path, active_path, error}
- src/api_hook_client.py: get_project_switch_status() helper
- tests/test_api_hooks_project_switch.py: 3 unit tests for client + endpoint
  shape, 1 live_gui test for the default-idle case
This commit is contained in:
2026-06-08 09:55:36 -04:00
parent c531cebe03
commit abb3856525
4 changed files with 91 additions and 0 deletions
+15
View File
@@ -358,6 +358,21 @@ class ApiHookClient:
"""
return self._make_request('GET', '/api/project') or {}
def get_project_switch_status(self) -> dict[str, Any]:
"""
Returns the project switch status: {in_progress, path, error}.
- in_progress: True when a project switch is currently scheduled or running
- path: the path the switch is targeting (or the last completed switch path)
- error: string error message if the last switch failed; None on success
Used by tests to wait deterministically for a project switch to complete
instead of blind-polling the project state.
[C: tests/test_api_hooks_project_switch.py]
"""
result = self._make_request('GET', '/api/project_switch_status')
if not result or not isinstance(result, dict):
return {"in_progress": False, "path": None, "error": None}
return result
def post_project(self, project_data: dict) -> dict[str, Any]:
"""
Updates the current project configuration.