diff --git a/README.md b/README.md index 45411df..f37f0f8 100644 --- a/README.md +++ b/README.md @@ -34,3 +34,32 @@ Create or refresh the local OWNER account: ```powershell docker compose run --rm backend python manage.py bootstrap_owner --email owner@edevs.tech --password local-owner-password --name "Иван Петров" ``` + +## Tests + +All suites run in Docker, so no manual environment is required — the test +runners auto-detect themselves and relax production hardening (secret-key +fail-fast, SSL redirect, throttling) for the duration of the run. + +Run everything (backend tests, frontend unit tests, typechecks): + +```powershell +.\scripts\check.ps1 +``` + +Individual suites: + +```powershell +# Backend (pytest + pytest-django) +docker compose run --rm backend pytest + +# Frontend unit tests (vitest) +docker compose run --rm internal-ui npm run test + +# End-to-end (Playwright, internal-ui) — auto-starts the dev server +npx playwright install chromium # one-time +npx playwright test --project=internal-ui +``` + +Backend pytest configuration lives in `apps/backend/pytest.ini` (it must sit +next to `manage.py` so it is also visible inside the backend container). diff --git a/apps/backend/pytest.ini b/apps/backend/pytest.ini new file mode 100644 index 0000000..7b7aa12 --- /dev/null +++ b/apps/backend/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +DJANGO_SETTINGS_MODULE = hub_backend.settings +python_files = tests.py test_*.py *_tests.py diff --git a/pyproject.toml b/pyproject.toml index b90285c..686ef51 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,11 +7,8 @@ src = ["apps/backend"] select = ["E", "F", "I", "UP", "B", "DJ"] ignore = ["DJ001"] -[tool.pytest.ini_options] -DJANGO_SETTINGS_MODULE = "hub_backend.settings" -pythonpath = ["apps/backend"] -testpaths = ["apps/backend"] -python_files = ["test_*.py", "*_tests.py"] +# pytest config lives in apps/backend/pytest.ini so it is also picked up inside +# the backend container (workdir /app/apps/backend, which does not mount this file). [tool.mypy] python_version = "3.12" diff --git a/scripts/check.ps1 b/scripts/check.ps1 index 516cee0..a6c4b53 100644 --- a/scripts/check.ps1 +++ b/scripts/check.ps1 @@ -1,6 +1,7 @@ $ErrorActionPreference = "Stop" -docker compose run --rm backend python manage.py test +docker compose run --rm backend pytest +docker compose run --rm internal-ui npm run test docker compose run --rm internal-ui npm run typecheck docker compose run --rm checkout npm run typecheck docker compose run --rm web-chat npm run typecheck