← ClaudeAtlas

write-api-testlisted

Use when adding a new API test to this Vexa repo — a JSON/HTTP endpoint test that authenticates by reusing a real browser login via ApiLibrary. Triggers include "write an API test for X", "add a test for this endpoint", "test the /api/... route", "verify this endpoint returns Y".
rohitmann721994/vexa · ★ 2 · Testing & QA · score 60
Install: claude install-skill rohitmann721994/vexa
# Write an API Test ## Overview Scaffold a new API test the way this framework expects: authenticate once through a real browser login (Playwright captures the session cookies), then hit JSON endpoints with an authenticated `requests.Session`. Read `CLAUDE.md` first — especially the **Authentication flow** section, which explains why login goes through a browser and how cookies are captured. ## Why it works this way The app sits behind an SPA + SSO login with no server-side form, so `requests` can't log in directly. `ApiLibrary` drives a browser login once per session, intercepts the raw `Cookie` header off the app's first authenticated request (keyed on `API_COOKIE_TRIGGER`, default `/api/`), and hands you an authenticated session. Tests just call `api_library.get(endpoint)`. ## Steps Track these as todos; do them in order. ### 1. Confirm the endpoint and expected shape Hit the endpoint in the browser (or via the app's network tab) while logged in. Note the path, the expected status, and the JSON shape you'll assert on. Confirm whether it needs query params or a specific account/role. ### 2. Set config in `.env` - `API_BASE_URL` — base for JSON endpoints (often the UI origin + `/api`). - `UI_BASE_URL`, `QA_USERNAME`, `QA_PASSWORD` — used for the one-time browser login. - `API_COOKIE_TRIGGER` — override if the app's authenticated requests don't hit `/api/` (e.g. `/gateway/`). ### 3. Write the test `tests/api/test_<feature>.py`. Follow `tests/api/test_example_api