diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 563c6a3333..a43abd21ee 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -25,3 +25,21 @@ updates: include: "scope" labels: - "dependencies" + - package-ecosystem: "docker" + directory: "/tests/playwright" # Playwright Docker image + schedule: + interval: "daily" + commit-message: + prefix: "chore" + include: "scope" + labels: + - "dependencies" + - package-ecosystem: "pip" + directory: "/tests/playwright" # Playwright pytest plugin + schedule: + interval: "daily" + commit-message: + prefix: "chore" + include: "scope" + labels: + - "dependencies" diff --git a/compose.yml b/compose.yml index c1a400b304..ae0c06979e 100644 --- a/compose.yml +++ b/compose.yml @@ -41,3 +41,12 @@ services: - "8000" volumes: - ./.devcontainer:/.devcontainer + + playwright: + build: + context: . + dockerfile: tests/playwright/Dockerfile + image: benefits_client:playwright + volumes: + - ./tests/playwright:/playwright + command: ./run.sh diff --git a/pyproject.toml b/pyproject.toml index a2b2080fc7..52845ef347 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,7 @@ test = [ "pytest", "pytest-django", "pytest-mock", + "pytest-playwright", # only for writing tests. run tests using playwright Docker Compose service "pytest-socket", ] diff --git a/tests/playwright/.gitignore b/tests/playwright/.gitignore new file mode 100644 index 0000000000..1a4b15330a --- /dev/null +++ b/tests/playwright/.gitignore @@ -0,0 +1,3 @@ +__pycache__ +.pytest_cache +test-results diff --git a/tests/playwright/Dockerfile b/tests/playwright/Dockerfile new file mode 100644 index 0000000000..f1cea1d8e1 --- /dev/null +++ b/tests/playwright/Dockerfile @@ -0,0 +1,11 @@ +# https://playwright.dev/docs/docker +FROM mcr.microsoft.com/playwright/python:v1.48.0-jammy + +WORKDIR /playwright + +COPY tests/playwright/requirements.txt requirements.txt + +RUN python -m pip install --upgrade pip && \ + pip install -r requirements.txt + +USER pwuser diff --git a/tests/playwright/pytest.ini b/tests/playwright/pytest.ini new file mode 100644 index 0000000000..03d2265ad3 --- /dev/null +++ b/tests/playwright/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +addopts = --tracing on -v --template=html1/index.html --report=test-results/report.html --video on diff --git a/tests/playwright/requirements.txt b/tests/playwright/requirements.txt new file mode 100644 index 0000000000..36aad0ab09 --- /dev/null +++ b/tests/playwright/requirements.txt @@ -0,0 +1,4 @@ +playwright==1.48.0 # needs to match version on Docker image +pytest +pytest-playwright +pytest-reporter-html1 diff --git a/tests/playwright/run.sh b/tests/playwright/run.sh new file mode 100755 index 0000000000..d390fc1e27 --- /dev/null +++ b/tests/playwright/run.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +set -e + +pytest diff --git a/tests/playwright/test_healthcheck.py b/tests/playwright/test_healthcheck.py new file mode 100644 index 0000000000..51b6ce9672 --- /dev/null +++ b/tests/playwright/test_healthcheck.py @@ -0,0 +1,7 @@ +from playwright.sync_api import Page, expect + + +def test_dev_healthcheck(page: Page): + page.goto("https://dev-benefits.calitp.org/healthcheck") + + expect(page.get_by_text("Healthy")).to_be_visible() diff --git a/tests/pytest/run.sh b/tests/pytest/run.sh index 8d06749e6a..fe384aaca8 100755 --- a/tests/pytest/run.sh +++ b/tests/pytest/run.sh @@ -2,7 +2,7 @@ set -eu # run normal pytests -coverage run -m pytest +coverage run -m pytest tests/pytest # clean out old coverage results rm -rf benefits/static/coverage