How J4H is tested โ unit tests, smoke tests, and regression
Run entirely locally against a temporary SQLite database.
No internet required. Tests Flask routes and API behavior
in isolation. Fast โ completes in under 2 seconds.
File: test_app.py
Make real HTTP requests to the live j4h.org and
Heroku URLs. Require internet. Verify the production site is
up, HTTPS is enforced, and every page returns 200.
File: test_smoke.py
/localStorage.removeItem in response)/, /entries, /calendar, /chart, /patient, /health-record, /quizzes/smart-info) returns 200/api/entries returns a JSON listsuccess: true and an entry_id/api/entries/:id removes the entry and returns successstart_date, end_date) are accepted/api/summaries returns a JSON list/api/summary/save with valid fields returns success/api/summary with no API key configured returns 503/api/smart/status returns JSON with authenticated and auth_method fieldsapp.db or PostgreSQL) is created when app.py is imported โ before any fixture runs. By replacing flask_app.db directly after import, each test gets a clean, empty database with no leftover data from previous runs.
https://j4h.org, https://www.j4h.org, https://j4h-be058543801b.herokuapp.comhttps:///passcode, /entries, /calendar, /chart, /vitals, /export, /import, /frontend-explainer, /backend-explainer, /project-explainertest_api_entries_reachable โ the entries API must return 200, 302, or 401 (not 500)test_static_crypto_js โ /static/crypto.js returns 200 and contains deriveAndStoreKeygit push heroku main). They confirm that the new code is live, all pages are reachable, HTTPS is working, and the encryption library was served correctly.
crypto.js runs in the browser using the Web Crypto API, which is not available in the Python test environment. Browser-level testing would require a tool like Playwright or Selenium.summarizer = None as a pattern for disabling external services./api/email-summary or /api/send-history endpoints.test_app.py is a regression guard โ if a future change breaks a route or API, the test catches it before deploymentcrypto.subtle not available error over HTTP, the Heroku DB fixture being replaced too late in the test lifecycletest_correct_passcode_redirects documents that 8903 redirects to /. test_generate_summary_without_api_key documents that a missing API key returns 503, not 500.
Run pytest test_app.py before every deploy to catch broken routes and API regressions locally,
then run pytest test_smoke.py after every deploy to confirm the live site is healthy.