From 8e292d1a2b6ab294566a7bbf2b3408d8297f0cb5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Feb 2026 07:43:22 +0000 Subject: [PATCH 1/3] Initial plan From 3c8f7ba44d8ffa9e8f603761dfcac441ae1923cd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Feb 2026 07:46:12 +0000 Subject: [PATCH 2/3] Add comprehensive tests for setup wizard redirect flow - Update test_root_endpoint to accept 303 status for setup wizard - Add test_root_redirects_to_setup_wizard_when_setup_required - Add test_root_returns_200_when_setup_complete - Add test_setup_wizard_page_accessible - Verify these tests now catch the missing RedirectResponse import issue - All new tests pass successfully Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> --- tests/test_api.py | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index 4a688c50..32120c95 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -10,9 +10,41 @@ class TestHealthEndpoints: """Tests for health check and status endpoints.""" def test_root_endpoint(self, client: TestClient): - """Test that root endpoint redirects to UI.""" + """Test that root endpoint redirects to UI or setup wizard.""" response = client.get("/", follow_redirects=False) - assert response.status_code in [200, 307, 308] # OK or redirect + # Accept 200 (OK), 303 (setup wizard redirect), 307/308 (other redirects) + assert response.status_code in [200, 303, 307, 308] + + def test_root_redirects_to_setup_wizard_when_setup_required(self, client: TestClient): + """Test that GET / redirects to setup wizard when setup is required.""" + # With test env vars (OPENAI_API_KEY=test-key, AZURE_AI_KEY=test-key), + # is_setup_required() returns True, so we should get a redirect to /setup + response = client.get("/", follow_redirects=False) + + # Should return 303 See Other (setup wizard redirect) + assert response.status_code == 303 + + # Location header should point to setup wizard + assert "Location" in response.headers + assert response.headers["Location"] == "/setup?step=1" + + # Should NOT be a 500 error + assert response.status_code != 500 + + def test_root_returns_200_when_setup_complete(self, client: TestClient): + """Test that GET /?setup=complete bypasses the setup wizard check.""" + # The ?setup=complete query param should bypass the wizard check + response = client.get("/?setup=complete", follow_redirects=False) + + # Should return 200 OK (renders the index page) + assert response.status_code == 200 + + def test_setup_wizard_page_accessible(self, client: TestClient): + """Test that GET /setup?step=1 returns 200.""" + response = client.get("/setup?step=1") + + # Setup wizard page should be accessible + assert response.status_code == 200 def test_docs_endpoint(self, client: TestClient): """Test that API documentation is accessible.""" From 276d6b90ebd78652c779f0cba6db10d431d5c706 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Feb 2026 07:46:58 +0000 Subject: [PATCH 3/3] Remove redundant assertion from test Address code review feedback by removing redundant check that status_code != 500, since we already assert status_code == 303 Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> --- tests/test_api.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index 32120c95..85ee78a5 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -27,9 +27,6 @@ class TestHealthEndpoints: # Location header should point to setup wizard assert "Location" in response.headers assert response.headers["Location"] == "/setup?step=1" - - # Should NOT be a 500 error - assert response.status_code != 500 def test_root_returns_200_when_setup_complete(self, client: TestClient): """Test that GET /?setup=complete bypasses the setup wizard check."""