From ad4600f81a6719ed139354307e3c9590f9f9b30c Mon Sep 17 00:00:00 2001 From: "Richard Kuo (Danswer)" Date: Fri, 15 Nov 2024 11:42:23 -0800 Subject: [PATCH] add playwright setup --- .github/workflows/pr-chromatic-tests.yml | 27 ++++++++++++++++--- .../tests/playwright/test_playwright.py | 18 +++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 backend/tests/integration/tests/playwright/test_playwright.py diff --git a/.github/workflows/pr-chromatic-tests.yml b/.github/workflows/pr-chromatic-tests.yml index 50ce55a6dec..955cfd86a85 100644 --- a/.github/workflows/pr-chromatic-tests.yml +++ b/.github/workflows/pr-chromatic-tests.yml @@ -24,6 +24,21 @@ jobs: with: fetch-depth: 0 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + cache: 'pip' + cache-dependency-path: | + backend/requirements/default.txt + backend/requirements/dev.txt + backend/requirements/model_server.txt + - run: | + python -m pip install --upgrade pip + pip install --retries 5 --timeout 30 -r backend/requirements/default.txt + pip install --retries 5 --timeout 30 -r backend/requirements/dev.txt + pip install --retries 5 --timeout 30 -r backend/requirements/model_server.txt + - name: Setup node uses: actions/setup-node@v4 with: @@ -138,9 +153,11 @@ jobs: done echo "Finished waiting for service." - - name: Run Playwright tests - working-directory: ./web - run: npx playwright test + - name: Run pytest playwright test init + working-directory: ./backend + env: + PYTEST_IGNORE_SKIP: true + run: pytest -s tests/integration/tests/playwright/test_playwright.py - uses: actions/upload-artifact@v4 if: always() @@ -180,18 +197,22 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Setup node uses: actions/setup-node@v4 with: node-version: 22 + - name: Install node dependencies working-directory: ./web run: npm ci + - name: Download Playwright test results uses: actions/download-artifact@v4 with: name: test-results path: ./web/test-results + - name: Run Chromatic uses: chromaui/action@latest with: diff --git a/backend/tests/integration/tests/playwright/test_playwright.py b/backend/tests/integration/tests/playwright/test_playwright.py new file mode 100644 index 00000000000..63c4dda7910 --- /dev/null +++ b/backend/tests/integration/tests/playwright/test_playwright.py @@ -0,0 +1,18 @@ +import os + +import pytest + +from tests.integration.common_utils.managers.user import UserManager +from tests.integration.common_utils.test_models import DATestUser + + +@pytest.mark.skipif( + os.getenv("PYTEST_IGNORE_SKIP") is None, + reason="Skipped by default unless env var exists", +) +def test_playwright_setup(reset: None) -> None: + """Not really a test, just using this to automate setup for playwright tests.""" + + # Creating an admin user (first user created is automatically an admin) + admin_user: DATestUser = UserManager.create(name="admin_user") + assert admin_user