Skip to content

Playwright Tests

Playwright Tests #149

Workflow file for this run

name: Playwright Tests
on:
workflow_dispatch:
inputs:
Browsers:
description: Browsers
required: true
default: firefox
type: choice
options:
- firefox
- chromium
TestSuite:
description: Test Suite to run
required: true
default: All
type: choice
options:
- All
- homePageTests
- topNavbarTests
- footerSectionTests
- contributePagesTests
- messagingSystem
- User Pages
- contactSupportPage
- productSolutionsPage
- productSupportPage
- productTopicsPage
- AAQ
- KB Articles
- kbRestrictedVisibility
- KB Article Translation
- recentRevisionsDashboard
- kbDashboard
- exploreByTopics
- searchTests
- contributorForumSearch
- userGroupsTests
- antiSpamTests
- contributorDiscussions
- contributorDiscussionsThreads
- userDeletion
- smokeTest
env:
TEST_ACCOUNTS_PS: ${{secrets.AUTOMATION_ACCOUNTS_PASSWORD}}
TEST_ACCOUNT_MODERATOR: ${{secrets.AUTOMATION_MODERATOR_ACCOUNT}}
PLAYWRIGHT_USER_AGENT: ${{secrets.PLAYWRIGHT_USER_AGENT}}
BROWSER: ${{secrets.BROWSER}}
DATABASE_URL: postgres://kitsune:kitsune@postgres:5432/kitsune
SECRET_KEY: secret
REDIS_DEFAULT_URL=: edis://redis:6379/1
REDIS_HELPFULVOTES_URL: redis://redis:6379/2
jobs:
playwright_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
if: success() || failure()
run: |
sudo apt-get update
pip3 install --user uv
uv venv
uv sync --extra dev
- name: Download NLTK Data
run: |
source .venv/bin/activate && python -m nltk.downloader wordnet omw-1.4
- name: Set up browsers env
run: |
echo "BROWSER=${{inputs.Browsers}}" >> $GITHUB_ENV
- name: Ensure Playwright browsers are installed
run: |
source .venv/bin/activate && playwright install ${{ env.BROWSER }}
- name: Creating User Sessions for ${{ env.BROWSER }}
id: create-sessions
working-directory: playwright_tests
run: |
source ../.venv/bin/activate && pytest -m loginSessions --browser ${{ env.BROWSER }} --reruns 1 -v
- name: Run ${{inputs.TestSuite}} Playwright Tests
working-directory: playwright_tests
if: success() || failure() && steps.create-sessions.outcome == 'success'
run: |
source ../.venv/bin/activate
declare dispatch_test_suite="${{inputs.TestSuite}}"
declare all_test_suites=("homePageTests" "topNavbarTests" "footerSectionTests" "contributePagesTests" "messagingSystem" "userContributionTests" "userProfile" "userSettings" "editUserProfileTests" "userQuestions" "contactSupportPage" "productSolutionsPage" "productSupportPage" "productTopicsPage" "aaqPage" "postedQuestions" "kbProductsPage" "kbArticleCreationAndAccess" "beforeThreadTests" "articleThreads" "afterThreadTests" "kbArticleShowHistory" "recentRevisionsDashboard" "kbDashboard" "kbRestrictedVisibility" "kbArticleTranslation" "exploreByTopics" "searchTests" "contributorForumSearch" "userGroupsTests" "antiSpamTests" "contributorDiscussions" "contributorDiscussionsThreads" "userDeletion")
if [ "$dispatch_test_suite" == "All" ] ; then
for test in "${all_test_suites[@]}"; do
if ! pytest -m ${test} --numprocesses 6 --browser ${{ env.BROWSER }} --reruns 2 -v; then
any_failures=true
fi
done
elif [ "$dispatch_test_suite" == "User Pages" ]; then
for test in "userContributionTests" "userProfile" "userSettings" "editUserProfileTests" "userQuestions"; do
if ! pytest -m ${test} --numprocesses 6 --browser ${{ env.BROWSER }} --reruns 2 -v; then
any_failures=true
fi
done
elif [ "$dispatch_test_suite" == "AAQ" ]; then
for test in "aaqPage" "postedQuestions"; do
if ! pytest -m ${test} --numprocesses 6 --browser ${{ env.BROWSER }} --reruns 2 -v; then
any_failures=true
fi
done
elif [ "$dispatch_test_suite" == "KB Articles" ]; then
for test in "kbProductsPage" "kbArticleCreationAndAccess" "beforeThreadTests" "articleThreads" "afterThreadTests" "kbArticleShowHistory"; do
if ! pytest -m ${test} --numprocesses 6 --browser ${{ env.BROWSER }} --reruns 2 -v; then
any_failures=true
fi
done
elif [ "$dispatch_test_suite" == "KB Article Translation" ]; then
if ! pytest -m kbArticleTranslation --numprocesses 6 --browser ${{ env.BROWSER }} --reruns 2 -v; then
any_failures=true
fi
else
if ! pytest -m $dispatch_test_suite --numprocesses 6 --browser ${{ env.BROWSER }} --reruns 2 -v; then
any_failures=true
fi
fi
echo "TESTS_FAILED=$any_failures" >> $GITHUB_ENV
- name: Generating Allure Report
working-directory: playwright_tests
if: always()
run: |
curl -o allure-2.32.0.tgz -L https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/2.32.0/allure-commandline-2.32.0.tgz
tar -zxvf allure-2.32.0.tgz
export PATH=$PATH:$PWD/allure-2.32.0/bin
allure generate --single-file reports/allure_reports
- name: Upload the combined test report as artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: Playwright test report
path: playwright_tests/allure-report
- name: Playwright Test Status
if: env.TESTS_FAILED == 'true'
run: exit 1