|
| 1 | +name: E2E Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, e2e-tests] |
| 6 | + pull_request: |
| 7 | + branches: [main, e2e-tests] |
| 8 | + |
| 9 | +jobs: |
| 10 | + playwright: |
| 11 | + name: Playwright Tests |
| 12 | + timeout-minutes: 60 |
| 13 | + runs-on: ubuntu-latest |
| 14 | + container: |
| 15 | + image: mcr.microsoft.com/playwright:v1.55.0-jammy |
| 16 | + |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Install dependencies |
| 21 | + run: npm ci |
| 22 | + |
| 23 | + - name: Build Next.js application |
| 24 | + run: npm run build |
| 25 | + env: |
| 26 | + NEXT_PUBLIC_WORKOS_REDIRECT_URI: ${{ vars.NEXT_PUBLIC_WORKOS_REDIRECT_URI }} |
| 27 | + |
| 28 | + - name: Run Playwright tests |
| 29 | + run: npx playwright test |
| 30 | + env: |
| 31 | + # Test environment variables |
| 32 | + WORKOS_API_KEY: ${{ secrets.WORKOS_API_KEY }} |
| 33 | + WORKOS_CLIENT_ID: ${{ secrets.WORKOS_CLIENT_ID }} |
| 34 | + WORKOS_COOKIE_PASSWORD: ${{ secrets.WORKOS_COOKIE_PASSWORD }} |
| 35 | + TEST_BASE_URL: http://localhost:3000 |
| 36 | + TEST_EMAIL: ${{ secrets.TEST_EMAIL }} |
| 37 | + TEST_PASSWORD: ${{ secrets.TEST_PASSWORD }} |
| 38 | + |
| 39 | + - name: Upload Playwright Report |
| 40 | + uses: actions/upload-artifact@v4 |
| 41 | + if: ${{ !cancelled() }} |
| 42 | + with: |
| 43 | + name: playwright-report |
| 44 | + path: playwright-report/ |
| 45 | + retention-days: 1 |
| 46 | + |
| 47 | + - name: Upload Test Results |
| 48 | + uses: actions/upload-artifact@v4 |
| 49 | + if: ${{ !cancelled() }} |
| 50 | + with: |
| 51 | + name: playwright-test-results |
| 52 | + path: test-results/ |
| 53 | + retention-days: 1 |
| 54 | + |
| 55 | + cypress: |
| 56 | + name: Cypress Tests |
| 57 | + timeout-minutes: 60 |
| 58 | + runs-on: ubuntu-latest |
| 59 | + |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@v4 |
| 62 | + |
| 63 | + - name: Setup Node.js |
| 64 | + uses: actions/setup-node@v4 |
| 65 | + with: |
| 66 | + node-version: 20 |
| 67 | + cache: "npm" |
| 68 | + |
| 69 | + - name: Install dependencies |
| 70 | + run: npm ci |
| 71 | + |
| 72 | + - name: Build Next.js application |
| 73 | + run: npm run build |
| 74 | + env: |
| 75 | + NEXT_PUBLIC_WORKOS_REDIRECT_URI: ${{ vars.NEXT_PUBLIC_WORKOS_REDIRECT_URI }} |
| 76 | + |
| 77 | + - name: Start Next.js application |
| 78 | + run: npm start & |
| 79 | + env: |
| 80 | + # Runtime environment variables for server |
| 81 | + WORKOS_API_KEY: ${{ secrets.WORKOS_API_KEY }} |
| 82 | + WORKOS_CLIENT_ID: ${{ secrets.WORKOS_CLIENT_ID }} |
| 83 | + WORKOS_COOKIE_PASSWORD: ${{ secrets.WORKOS_COOKIE_PASSWORD }} |
| 84 | + PORT: 3000 |
| 85 | + |
| 86 | + - name: Wait for application to start |
| 87 | + run: | |
| 88 | + timeout 30 bash -c 'until curl -s http://localhost:3000 > /dev/null; do sleep 1; done' |
| 89 | +
|
| 90 | + - name: Run Cypress tests |
| 91 | + run: npm run test:cypress |
| 92 | + env: |
| 93 | + # Test environment variables |
| 94 | + WORKOS_API_KEY: ${{ secrets.WORKOS_API_KEY }} |
| 95 | + WORKOS_CLIENT_ID: ${{ secrets.WORKOS_CLIENT_ID }} |
| 96 | + WORKOS_COOKIE_PASSWORD: ${{ secrets.WORKOS_COOKIE_PASSWORD }} |
| 97 | + TEST_BASE_URL: http://localhost:3000 |
| 98 | + TEST_EMAIL: ${{ secrets.TEST_EMAIL }} |
| 99 | + TEST_PASSWORD: ${{ secrets.TEST_PASSWORD }} |
| 100 | + |
| 101 | + - name: Upload Cypress Screenshots |
| 102 | + uses: actions/upload-artifact@v4 |
| 103 | + if: failure() |
| 104 | + with: |
| 105 | + name: cypress-screenshots |
| 106 | + path: cypress/screenshots |
| 107 | + retention-days: 1 |
| 108 | + |
| 109 | + - name: Upload Cypress Videos |
| 110 | + uses: actions/upload-artifact@v4 |
| 111 | + if: failure() |
| 112 | + with: |
| 113 | + name: cypress-videos |
| 114 | + path: cypress/videos |
| 115 | + retention-days: 1 |
0 commit comments