Skip to content

Commit

Permalink
Setup and migrate Discover tests to playwright (#2807)
Browse files Browse the repository at this point in the history
* setup and migrate some discover tests to playwright

* Add request and date mock utils

* Add the rest of discover tests

* Add playwright workflow

* Trigger Build

* Add server command

* Trigger Build

* run server in the background

* Trigger Build

* let playwright start local server

* Trigger Build

* increase timeout

* upload test reports

* Trigger Build

* Fix report path

* Trigger Build

* Fix wrong timeout

* Trigger Build

* Increase timeouts on CI

* Trigger Build

* Refactor intercept functions to closely resemble old cypress api

* Add doc link

* Move tests to e2e folder

* Add cite page tests

* update lockfile

* Add missing env vars

* Trigger Build

* fix tests
  • Loading branch information
cesarvarela authored Jun 6, 2024
1 parent 8606c15 commit 78feb35
Show file tree
Hide file tree
Showing 18 changed files with 9,362 additions and 7,119 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ jobs:
environment: staging
runner-label: ${{ vars.PREVIEW_RUNNER_LABEL }}

call-test-playwright:
if: ${{ !failure() && !cancelled() }}
uses: ./.github/workflows/test-playwright.yml
needs: call-test-build
secrets: inherit
with:
sha: ${{ github.event.pull_request.head.sha }}
environment: staging
runner-label: ${{ vars.PREVIEW_RUNNER_LABEL }}

call-deploy:
if: ${{ !failure() && !cancelled() }}
uses: ./.github/workflows/deploy.yml
Expand Down
80 changes: 80 additions & 0 deletions .github/workflows/test-playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Run playwright tests
on:
workflow_call:
inputs:
environment:
description: The Github environment to load secrets from
type: string
required: true
sha:
description: The commit SHA to run the tests against
type: string
required: true
runner-label:
description: The label of the runner to use
type: string
cache-modifier:
description: A modifier for the cache key used to bypass existing cache
type: string
required: false
default: ""

jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.sha }}

- uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Read node modules from cache
id: cache-nodemodules
uses: actions/cache/restore@v4
env:
cache-name: cache-install-folder
with:
path: |
site/gatsby-site/node_modules
~/.cache/Cypress
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}-${{ inputs.cache-modifier }}

- name: Install NPM dependencies
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: npm ci
working-directory: site/gatsby-site

- name: Restore build cache
uses: actions/cache/restore@v4
env:
cache-name: cache-build-folder
with:
path: |
site/gatsby-site/public
site/gatsby-site/.cache/functions
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ inputs.sha }}-${{ inputs.cache-modifier }}

- name: Install playwright browsers
run: npx playwright install --with-deps
working-directory: site/gatsby-site

- name: Run playwright tests
run: npx playwright test
working-directory: site/gatsby-site
env:
E2E_ADMIN_PASSWORD: ${{ secrets.E2E_ADMIN_PASSWORD }}
E2E_ADMIN_USERNAME: ${{ secrets.E2E_ADMIN_USERNAME }}
IS_EMPTY_ENVIRONMENT: ${{ vars.IS_EMPTY_ENVIRONMENT }}

- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: site/gatsby-site/playwright-report/
retention-days: 1

6 changes: 5 additions & 1 deletion site/gatsby-site/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ node_modules
.idea/

# Local Netlify folder
.netlify
.netlify
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
Loading

0 comments on commit 78feb35

Please sign in to comment.