Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .env.test.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Test Environment Variables
# Copy this file to .env.test and fill in your values

# WordPress API Configuration
WORDPRESS_API_URL=https://wp.keploy.io/graphql
NEXT_PUBLIC_WORDPRESS_API_URL=https://wp.keploy.io/graphql

# Test Configuration
# Base URL for the application under test
BASE_URL=http://localhost:3000/blog

# Set to 'true' to use real WordPress API instead of mocks for all tests
TEST_USE_REAL_API=false

# Timeouts (milliseconds)
TEST_TIMEOUT=30000
TEST_EXPECT_TIMEOUT=10000
TEST_ACTION_TIMEOUT=15000
TEST_NAVIGATION_TIMEOUT=30000

# Dev server timeout (milliseconds)
WEB_SERVER_TIMEOUT=120000
74 changes: 74 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Playwright E2E Tests

on:
pull_request:
branches: [ main, master ]
push:
branches: [ main, master ]

jobs:
test:
name: E2E Tests (${{ matrix.browser }})
timeout-minutes: 20
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
browser: [chromium] # Start with Chromium only, add more browsers later

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Install Playwright Browsers
run: npx playwright install --with-deps ${{ matrix.browser }}

- name: Run Playwright tests
run: npm run test:e2e -- --project=${{ matrix.browser }}
env:
WORDPRESS_API_URL: ${{ secrets.WORDPRESS_API_URL }}
NEXT_PUBLIC_WORDPRESS_API_URL: ${{ secrets.NEXT_PUBLIC_WORDPRESS_API_URL }}

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.browser }}
path: test-results/e2e/
retention-days: 30

- name: Upload test report
if: failure()
uses: actions/upload-artifact@v4
with:
name: playwright-report-${{ matrix.browser }}
path: playwright-report/
retention-days: 30

- name: Comment PR with result
if: github.event_name == 'pull_request' && always()
uses: actions/github-script@v7
with:
script: |
const status = '${{ job.status }}';
const emoji = status === 'success' ? '✅' : '❌';
const message = status === 'success'
? `${emoji} Playwright tests passed on **${{ matrix.browser }}**!`
: `${emoji} Playwright tests failed on **${{ matrix.browser }}**. Check the [workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.`;

github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: message
});
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ yarn-debug.log*
yarn-error.log*

# local env files
.env*
.env
.env*.local
.env.test

# vercel
.vercel
Expand All @@ -37,3 +39,11 @@ yarn-error.log*
next-env.d.ts

.early.coverage

# Playwright
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
/playwright/.auth/
120 changes: 95 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading