Skip to content

Playwright Tests

Playwright Tests #333

Workflow file for this run

name: Playwright Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: '0 */3 * * 1-5'
repository_dispatch:
types: [ run_e2e_tests ]
workflow_dispatch:
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
env:
TEST_USER_USERNAME: ${{ secrets.TEST_USER_USERNAME }}
TEST_USER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
- name: Send Discord notification
if: failure()
env:
DISCORD_JAQPOT_ALERTS_WEBHOOK: ${{ secrets.DISCORD_JAQPOT_ALERTS_WEBHOOK }}
run: |
curl -H "Content-Type: application/json" -X POST -d '{
"username": "GitHub Actions",
"avatar_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
"content": "End-to-end tests failed! Check the report for details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}' $DISCORD_JAQPOT_ALERTS_WEBHOOK
- name: Send screenshot to Discord
if: failure()
env:
DISCORD_JAQPOT_ALERTS_WEBHOOK: ${{ secrets.DISCORD_JAQPOT_ALERTS_WEBHOOK }}
run: |
SCREENSHOT=$(find test-results -name "test-failed-1.png" | head -n 1)
if [ -n "$SCREENSHOT" ]; then
curl -H "Content-Type: multipart/form-data" -X POST -F "file=@$SCREENSHOT" -F "content=E2E Test failed. Here's a screenshot of the failure:" $DISCORD_JAQPOT_ALERTS_WEBHOOK
else
curl -H "Content-Type: application/json" -X POST -d '{"content":"E2E Test failed, but no screenshot was found."}' $DISCORD_JAQPOT_ALERTS_WEBHOOK
fi
- name: Send screenshot to Discord
if: failure()
env:
DISCORD_JAQPOT_ALERTS_WEBHOOK: ${{ secrets.DISCORD_JAQPOT_ALERTS_WEBHOOK }}
run: |
VIDEO=$(find test-results -name "video.webm" | head -n 1)
if [ -n "$VIDEO" ]; then
curl -H "Content-Type: multipart/form-data" -X POST -F "file=@$VIDEO" -F "content=E2E Test failed. Here's a video of the failure:" $DISCORD_JAQPOT_ALERTS_WEBHOOK
else
curl -H "Content-Type: application/json" -X POST -d '{"content":"E2E Test failed, but no video was found."}' $DISCORD_JAQPOT_ALERTS_WEBHOOK
fi