diff --git a/Auto Run Docs/SpecKit-web-header-analyzer-Phase-04-Test-Selection.md b/Auto Run Docs/SpecKit-web-header-analyzer-Phase-04-Test-Selection.md index d07f955..ca5b53e 100644 --- a/Auto Run Docs/SpecKit-web-header-analyzer-Phase-04-Test-Selection.md +++ b/Auto Run Docs/SpecKit-web-header-analyzer-Phase-04-Test-Selection.md @@ -21,7 +21,7 @@ This phase implements the test selection panel and analysis configuration contro ## Tasks - [x] T020 [US2] Write failing test (TDD Red) in `backend/tests/api/test_tests_router.py` — verify `GET /api/tests` returns 200 with all registered test IDs and names. Use httpx AsyncClient against the FastAPI test app -- [ ] T021 [US2] Create `backend/app/schemas/tests.py` (response schema) and `backend/app/routers/tests.py` — FastAPI router with `GET /api/tests` returning all available tests (id, name, category) from scanner registry. Register router in `backend/app/main.py`. Verify `test_tests_router.py` passes (TDD Green) +- [x] T021 [US2] Create `backend/app/schemas/tests.py` (response schema) and `backend/app/routers/tests.py` — FastAPI router with `GET /api/tests` returning all available tests (id, name, category) from scanner registry. Register router in `backend/app/main.py`. Verify `test_tests_router.py` passes (TDD Green) - [ ] T022 [US2] Write failing tests (TDD Red) in `frontend/src/__tests__/TestSelector.test.tsx` (render with mocked list, select/deselect all, search filtering) and `frontend/src/__tests__/AnalysisControls.test.tsx` (render, toggle states, keyboard accessibility) - [ ] T023 [P] [US2] Create `frontend/src/components/TestSelector.tsx` — dropdown with checkboxes per test, fetches list from `GET /api/tests`, "Select All"/"Deselect All" buttons (FR-04), text search/filter (FR-23), grouped by vendor/category (FR-24), FontAwesome icons. Verify `TestSelector.test.tsx` passes (TDD Green) - [ ] T024 [P] [US2] Create `frontend/src/components/AnalysisControls.tsx` — panel containing TestSelector, DNS resolution toggle (off by default, FR-18), decode-all toggle (FR-19), FontAwesome toggle icons, keyboard accessible (NFR-02). Verify `AnalysisControls.test.tsx` passes (TDD Green) diff --git a/backend/app/main.py b/backend/app/main.py index 9b3db6f..94e3714 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -1,6 +1,9 @@ from fastapi import FastAPI +from app.routers.tests import router as tests_router + app = FastAPI(title="Web Header Analyzer API") +app.include_router(tests_router) @app.get("/") diff --git a/backend/app/routers/__init__.py b/backend/app/routers/__init__.py new file mode 100644 index 0000000..c5cfac8 --- /dev/null +++ b/backend/app/routers/__init__.py @@ -0,0 +1 @@ +"""FastAPI routers.""" diff --git a/backend/app/routers/tests.py b/backend/app/routers/tests.py new file mode 100644 index 0000000..cee004e --- /dev/null +++ b/backend/app/routers/tests.py @@ -0,0 +1,15 @@ +from __future__ import annotations + +from fastapi import APIRouter + +from app.engine.scanner_registry import ScannerRegistry +from app.schemas.tests import TestResponse + +router = APIRouter(prefix="/api", tags=["tests"]) + + +@router.get("/tests", response_model=list[TestResponse]) +def list_tests() -> list[TestResponse]: + registry = ScannerRegistry() + tests = registry.list_tests() + return [TestResponse.model_validate(test) for test in tests] diff --git a/backend/app/schemas/__init__.py b/backend/app/schemas/__init__.py new file mode 100644 index 0000000..3fea1a0 --- /dev/null +++ b/backend/app/schemas/__init__.py @@ -0,0 +1 @@ +"""API response schemas.""" diff --git a/backend/app/schemas/tests.py b/backend/app/schemas/tests.py new file mode 100644 index 0000000..cb29e69 --- /dev/null +++ b/backend/app/schemas/tests.py @@ -0,0 +1,7 @@ +from __future__ import annotations + +from app.engine.models import Test + + +class TestResponse(Test): + pass