Skip to content

Frontend e2e tests #106

Frontend e2e tests

Frontend e2e tests #106

name: Frontend e2e tests
on:
workflow_run:
workflows: ["Continuous Integration"]
branches: [main]
types:
- completed
workflow_dispatch:
inputs:
run_frontend_e2e_tests:
description: Run e2e tests of frontend app
required: false
type: boolean
env:
FUSIONAUTH_HOST: "http://localhost:9011"
FUSIONAUTH_ISSUER: "http://localhost:9011"
FUSIONAUTH_API_KEY: "fusionauth_api_key_${{ github.run_id }}_${{ github.run_attempt }}"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres-password-${{ github.run_id }}-${{ github.run_attempt }}"
FUSIONAUTH_POSTGRESQL_PASSWORD: "fusionauth-postgresql-password-${{ github.run_id }}-${{ github.run_attempt }}"
MONGO_INITDB_DATABASE: "you-say"
MONGO_INITDB_ROOT_USERNAME: "mongodb-root-user-${{ github.run_id }}-${{ github.run_attempt }}"
MONGO_INITDB_ROOT_PASSWORD: "mongodb-root-password-${{ github.run_id }}-${{ github.run_attempt }}"
OAUTH_CONFIGURATION_CLIENT_SECRET: "client_secret_${{ github.run_id }}_${{ github.run_attempt }}"
NODE_ENV: "production"
FRONTEND_URL: "http://localhost:3000"
FUSIONAUTH_OAUTH_SCOPES: "offline_access openid"
jobs:
build-and-test-frontend-e2e:
runs-on: ubuntu-22.04
timeout-minutes: 45
if: ${{
github.event.workflow_run.conclusion == 'success' ||
github.event_name == 'workflow_dispatch' && inputs.run_frontend_e2e_tests == true }}
steps:
- name: Clone you-say repo in Ubuntu
uses: actions/checkout@v4
- name: Check if the changes were made to our backend or frontend application
uses: dorny/paths-filter@v3
id: changed-paths
with:
filters: |
is-backend-or-frontend:
- 'apps/backend/**'
- 'apps/frontend/**'
- 'apps/frontend-e2e/**'
- 'libs/backend/auth/**'
- '.github/workflows/frontend-e2e-tests.workflow.yml'
- if: ${{ steps.changed-paths.outputs.is-backend-or-frontend == 'true' }}
name: Setup docker
uses: ./.github/actions/setup-docker-composite
- if: ${{ steps.changed-paths.outputs.is-backend-or-frontend == 'true' }}
name: Build and start backend application + FusionAuth
uses: ./.github/actions/backend-app-composite
with:
fusionauth_api_key: ${{ env.FUSIONAUTH_API_KEY }}
- if: ${{ steps.changed-paths.outputs.is-backend-or-frontend == 'true' }}
name: Configuring infrastructure with terraform
id: terraform
uses: ./.github/actions/terraform-composite
with:
fusionauth_host: ${{ env.FUSIONAUTH_HOST }}
fusionauth_issuer: ${{ env.FUSIONAUTH_ISSUER }}
fusionauth_api_key: ${{ env.FUSIONAUTH_API_KEY }}
oauth_configuration_client_secret: ${{ env.OAUTH_CONFIGURATION_CLIENT_SECRET }}
fusionauth_email_configuration_password: ${{ env.FUSIONAUTH_EMAIL_CONFIGURATION_PASSWORD }}
- if: ${{ steps.changed-paths.outputs.is-backend-or-frontend == 'true' }}
name: Starting backend service
run: docker compose up -d
env:
FUSIONAUTH_TENANT_ID: ${{ steps.terraform.outputs.fusionauth_tenant_id }}
FUSIONAUTH_APPLICATION_ID: ${{ steps.terraform.outputs.fusionauth_application_id }}
FUSIONAUTH_ADMIN_GROUP_ID: ${{ steps.terraform.outputs.fusionauth_admin_group_id }}
DATABASE_URL: "mongodb://${{ env.MONGO_INITDB_ROOT_USERNAME }}:${{ env.MONGO_INITDB_ROOT_PASSWORD }}@localhost:27017"
- if: ${{ steps.changed-paths.outputs.is-backend-or-frontend == 'true' }}
# https://stackoverflow.com/a/77972789/8784518
name: Install cypress binary
run: npx cypress install
- if: ${{ steps.changed-paths.outputs.is-backend-or-frontend == 'true' }}
name: Execute e2e tests
run: npx nx e2e frontend-e2e
env:
NEXT_PUBLIC_BACKEND_BASE_URL: "http://localhost:3001"
NEXT_PUBLIC_NODE_ENV: ${{ env.NODE_ENV }}
NEXT_PUBLIC_FRONTEND_URL: ${{ env.FRONTEND_URL }}
NEXT_PUBLIC_FUSIONAUTH_APPLICATION_ID: ${{ steps.terraform.outputs.fusionauth_application_id }}