From fb4d690172bb75a477aa7fd319409845b6e94f23 Mon Sep 17 00:00:00 2001 From: Becky Smith Date: Wed, 21 Aug 2024 17:57:17 +0100 Subject: [PATCH] Skip screenshot tests by default They can be run by setting an enviroment variable. Run the screenshot tests in CI; they will generate new screenshots, but we only care (in CI) about checking that they don't fail. --- .github/workflows/main.yml | 2 +- dotenv-sample | 3 +++ tests/functional/test_docs_screenshots.py | 10 ++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d9d002de..41411548 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,7 +38,7 @@ jobs: - name: Run tests run: | - just test-all + RUN_SCREENSHOT_TESTS=True just test-all # not actually needed for tests, but we want to make sure the dev tooling # is still working diff --git a/dotenv-sample b/dotenv-sample index a1153c5f..279e7f45 100644 --- a/dotenv-sample +++ b/dotenv-sample @@ -33,3 +33,6 @@ OTEL_EXPORTER_CONSOLE=False # To send to honecomb in dev, create a token for the development and set it here. # OTEL_EXPORTER_OTLP_HEADERS="x-honeycomb-team=TOKEN34" + +# Uncomment to run the tests that take docs screenshots +# RUN_SCREENSHOT_TESTS=True diff --git a/tests/functional/test_docs_screenshots.py b/tests/functional/test_docs_screenshots.py index 95a7730d..2a658cc8 100644 --- a/tests/functional/test_docs_screenshots.py +++ b/tests/functional/test_docs_screenshots.py @@ -1,5 +1,7 @@ +import os import re +import pytest from django.conf import settings from playwright.sync_api import expect @@ -19,6 +21,10 @@ } +@pytest.mark.skipif( + os.getenv("RUN_SCREENSHOT_TESTS") is None, + reason="screenshot tests skipped; set RUN_SCREENSHOT_TESTS env variable", +) def test_screenshot_from_creation_to_release( page, live_server, context, release_files_stubber ): @@ -266,6 +272,10 @@ def do_review_and_approve(username): page.screenshot(path=settings.SCREENSHOT_DIR / "files_released.png") +@pytest.mark.skipif( + os.getenv("RUN_SCREENSHOT_TESTS") is None, + reason="screenshot tests skipped; set RUN_SCREENSHOT_TESTS env variable", +) def test_screenshot_withdraw_request(page, context, live_server): user = factories.create_user(**USER_DATA["author"]) release_request = factories.create_request_at_status(