LESSON OBJECTIVE
What you will be able to do
Verify complete HTTP contracts and reserve browser automation for behavior only a browser can prove.
Test status, headers, and body
Assert the contract: status, content type, cache/security headers, redirects, and stable JSON or HTML meaning.
GET /health → 200 application/json
POST /admin/news without CSRF → 403
GET /missing → 404Exercise authentication and CSRF
Cover anonymous, authenticated, forbidden, invalid CSRF, expired session, and successful actions. Security middleware deserves direct regression tests.
Keep browser tests selective
Use browser automation for interactions the lower layers cannot prove: focus, history, forms, responsive menus, View hydration, and accessibility.
CHECKPOINT
Before you continue
Do tests cover anonymous, forbidden, invalid, missing, failure, and successful responses—not only status 200?