Skip to content

E2E Tests

E2E Tests #283

Workflow file for this run

name: E2E Tests
on:
workflow_dispatch:
inputs:
environment:
required: true
description: "Environment to run tests against"
default: "https://staging-demo.saleor.io/"
type: choice
options:
- https://staging-demo.saleor.io/
- https://demo.saleor.io/
- https://react-storefront-e2e.vercel.app/
schedule:
- cron: "00 2 * * 1-5"
repository_dispatch:
types: [automation-tests-event]
jobs:
cypress-run:
runs-on: ubuntu-latest
outputs:
status: ${{ steps.cypress.outcome }}
dashboard_url: ${{ steps.cypress.outputs.dashboardUrl }}
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v3
with:
node-version: "16"
cache: "pnpm"
- name: Get env for release testing
if: ${{ github.event_name == 'repository_dispatch' }}
id: get-env-uri-for-release
env:
DEFAULT_ENV_URI: "https://staging-demo.saleor.io/"
run: |
echo "RELEASE_ENV_URI=${{ env.DEFAULT_ENV_URI }}" >> $GITHUB_OUTPUT
- name: Get env
id: get-env-uri
env:
DEFAULT_ENV_URI: "https://react-storefront-e2e.vercel.app/"
run: |
echo "ENV_URI=${{ steps.get-env-uri-for-release.outputs.RELEASE_ENV_URI || github.event.inputs.environment || env.DEFAULT_ENV_URI }}" >> $GITHUB_OUTPUT
- name: Get BE url and variables for demo
id: demo
if: ${{ contains(steps.get-env-uri.outputs.ENV_URI, 'demo') }}
run: |
echo "SALEOR_API_URL=${{steps.get-env-uri.outputs.ENV_URI}}graphql/" >> $GITHUB_OUTPUT
echo "CYPRESS_USER_EMAIL=${{'admin@example.com'}}" >> $GITHUB_OUTPUT
echo "CYPRESS_USER_PASSWORD=${{'admin'}}" >> $GITHUB_OUTPUT
echo "CYPRESS_DIGITAL_PRODUCT=cloud" >> $GITHUB_OUTPUT
echo "CYPRESS_WITH_VARIANTS=zoom" >> $GITHUB_OUTPUT
echo "CYPRESS_WITHOUT_VARIANTS=beanie" >> $GITHUB_OUTPUT
echo "CYPRESS_PRODUCT_TO_SEARCH=polo" >> $GITHUB_OUTPUT
- name: Get BE url and variables for non demo environment
id: testenv
if: ${{ !contains(steps.get-env-uri.outputs.ENV_URI, 'demo') }}
run: |
echo "SALEOR_API_URL=https://storefront-automation.staging.saleor.cloud/graphql/" >> $GITHUB_OUTPUT
echo "CYPRESS_USER_EMAIL=testers+dashboard@saleor.io" >> $GITHUB_OUTPUT
echo "CYPRESS_USER_PASSWORD=${{secrets.CYPRESS_USER_PASSWORD}}" >> $GITHUB_OUTPUT
echo "CYPRESS_DIGITAL_PRODUCT=sea" >> $GITHUB_OUTPUT
echo "CYPRESS_WITH_VARIANTS=carrot" >> $GITHUB_OUTPUT
echo "CYPRESS_WITHOUT_VARIANTS=lager" >> $GITHUB_OUTPUT
echo "CYPRESS_PRODUCT_TO_SEARCH=polo" >> $GITHUB_OUTPUT
- name: Cypress run
id: cypress
uses: cypress-io/github-action@v4
with:
record: true
config: baseUrl=${{ steps.get-env-uri.outputs.ENV_URI }}
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SALEOR_API_URL: ${{ steps.demo.outputs.SALEOR_API_URL || steps.testenv.outputs.SALEOR_API_URL }}
CYPRESS_USER_EMAIL: ${{ steps.demo.outputs.CYPRESS_USER_EMAIL || steps.testenv.outputs.CYPRESS_USER_EMAIL}}
CYPRESS_USER_PASSWORD: ${{ steps.demo.outputs.CYPRESS_USER_PASSWORD || steps.testenv.outputs.CYPRESS_USER_PASSWORD }}
CYPRESS_DIGITAL_PRODUCT: ${{ steps.demo.outputs.CYPRESS_DIGITAL_PRODUCT || steps.testenv.outputs.CYPRESS_DIGITAL_PRODUCT }}
CYPRESS_WITHOUT_VARIANTS: ${{ steps.demo.outputs.CYPRESS_WITHOUT_VARIANTS || steps.testenv.outputs.CYPRESS_WITHOUT_VARIANTS }}
CYPRESS_WITH_VARIANTS: ${{ steps.demo.outputs.CYPRESS_WITHOUT_VARIANTS || steps.testenv.outputs.CYPRESS_WITHOUT_VARIANTS }}
CYPRESS_PRODUCT_TO_SEARCH: ${{ steps.demo.outputs.CYPRESS_PRODUCT_TO_SEARCH || steps.testenv.outputs.CYPRESS_PRODUCT_TO_SEARCH}}
add-comment-to-release-pull-request:
if: ${{ always() && github.event_name == 'repository_dispatch' }}
runs-on: ubuntu-latest
needs: [cypress-run]
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v3
with:
node-version: "16"
- name: Install dependencies
run: |
cd .github/workflows
npm ci
- name: add comment do release PR
env:
tests_status: ${{ needs.cypress-run.outputs.status }}
version: ${{ github.event.client_payload.version }}
pull_request_number: ${{ github.event.client_payload.pullRequestNumber }}
dashboard_url: ${{ needs.cypress-run.outputs.dashboard_url }}
run: |
export GITHUB_TOKEN=$( \
curl --request GET --url ${{ secrets.VAULT_URL}} --header "Authorization: JWT ${{ secrets.VAULT_JWT }}" | jq -r .token \
)
node .github/workflows/addCommentToReleasePR.js \
--version $version \
--pull_request_number $pull_request_number \
--dashboard_url $dashboard_url