Skip to content

chore: Add playwright tests for app in local-only mode #11

chore: Add playwright tests for app in local-only mode

chore: Add playwright tests for app in local-only mode #11

Workflow file for this run

name: E2E Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_call:
# Allow this workflow to be called by other workflows
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
e2e-tests:
name: End-to-End Tests
runs-on: ubuntu-24.04
timeout-minutes: 15
container:
image: mcr.microsoft.com/playwright:v1.55.0-jammy
permissions:
contents: read
pull-requests: write
issues: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache-dependency-path: 'yarn.lock'
cache: 'yarn'
- name: Install dependencies
run: yarn install
- name: Build dependencies
run: npx nx run-many -t ci:build
- name: Run Playwright tests
run: |
cd packages/app
yarn test:e2e
- name: Upload Playwright report
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: packages/app/playwright-report/
retention-days: 30
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: packages/app/test-results/
retention-days: 30
- name: Comment PR with test results
uses: actions/github-script@v7
if: always() && github.event_name == 'pull_request'
with:
script: |
const fs = require('fs');
const path = require('path');
try {
const resultsPath = path.join('packages/app/test-results/results.json');
if (fs.existsSync(resultsPath)) {
const results = JSON.parse(fs.readFileSync(resultsPath, 'utf8'));
const { stats } = results;
const total = stats.expected + stats.unexpected + stats.flaky + stats.skipped;
const failed = stats.unexpected > 0;
const summary = failed
? `> 🚨 **Test Run Failed** – ${stats.unexpected} failing test(s)`
: `> ✅ **All Tests Passed!** 🎉`;
const table = `
| Metric | Count |
|----------|-------|
| 🧪 Total | ${total} |
| ✅ Passed | ${stats.expected} |
| ❌ Failed | ${stats.unexpected} |
| ⚠️ Flaky | ${stats.flaky} |
| ⏭️ Skipped | ${stats.skipped} |
| ⏱ Duration | ${Math.round(stats.duration / 1000)}s |
`;
const link = `[📊 View full Playwright report](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})`;
const body = `## 🎭 Playwright Test Results
${summary}
<details>
<summary>📖 Detailed Results</summary>
${table}
</details>
${link}
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});
}
} catch (error) {
console.log('Could not post test results:', error.message);
}