Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add e2e smoke test #507

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e941cc2
chore: add e2e smoke job
jenniferarnesen Apr 30, 2024
5767750
chore: fix syntax error
jenniferarnesen Apr 30, 2024
a1b3224
chore: add user and sys settings check
jenniferarnesen Apr 30, 2024
9451146
chore: try adding a step to e2e-prod
jenniferarnesen Apr 30, 2024
828a17b
chore: make test fail
jenniferarnesen Apr 30, 2024
ef537f0
chore: make test pass
jenniferarnesen Apr 30, 2024
fe29545
chore: consolidate to 2 tests and insert failure for testing
jenniferarnesen May 2, 2024
d760224
chore: fix broken test
jenniferarnesen May 2, 2024
42638c3
chore: additional checks for analytics request
jenniferarnesen May 2, 2024
aea09c7
chore: statusCode not status
jenniferarnesen May 3, 2024
b9054aa
Merge branch 'master' into chore/e2e-optimization
jenniferarnesen May 6, 2024
ce4a712
fix: record cypress [e2e record]
jenniferarnesen May 6, 2024
91ce435
Merge branch 'chore/e2e-optimization' of github.com:dhis2/line-listin…
jenniferarnesen May 6, 2024
08cef8d
chore: remove smoke test to see if it is the culprit
jenniferarnesen May 6, 2024
5aa7637
chore: add smoke tests in again
jenniferarnesen May 6, 2024
0ef8746
chore: try using different gh jobs
jenniferarnesen May 8, 2024
25f66c9
chore: wrong filename
jenniferarnesen May 8, 2024
d700aa3
chore: lint
jenniferarnesen May 8, 2024
4e47975
chore: only 1 container needed for smoke tests
jenniferarnesen May 8, 2024
c0b97c7
chore: not needed
jenniferarnesen May 13, 2024
6b9f2d2
Merge branch 'master' into chore/e2e-optimization
jenniferarnesen Dec 4, 2024
56a02cf
Merge branch 'master' into chore/e2e-optimization
jenniferarnesen Dec 5, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/dhis2-verify-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
call-workflow-e2e-prod:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
needs: [build, lint, test]
uses: dhis2/workflows/.github/workflows/analytics-e2e-tests-prod.yml@master
uses: ./.github/workflows/e2e-prod.yml
with:
should_record: ${{ contains(github.event.head_commit.message, '[e2e record]') || contains(join(github.event.pull_request.labels.*.name), 'e2e record')}}
secrets:
Expand Down
150 changes: 150 additions & 0 deletions .github/workflows/e2e-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
name: 'e2e-prod'

# Requirements:
#
# - Customize environment variables:
# BASE_URL_INSTANCES: Set the base url for the instances, e.g. https://test.e2e.dhis2.org
# NAME_PATTERN_PROD_INSTANCES: Set the name pattern for your instances. {version} will be replaced by "[majorVersion].[minorVersion]"
#
# - Other optional customizations:
# containers: Set the matrix containers array for the e2e-prod job. The number of parallel Cypress instances running for each backend version will equal the array length.
#
# - Set status check as required:
# We recommend setting "e2e-tests-success" as a required step in your workflow.

on:
workflow_call:
inputs:
should_record:
required: false
type: boolean
default: false
secrets:
username:
required: true
password:
required: true
recordkey:
required: true
reportportal_api_key:
required: false
reportportal_endpoint:
required: false
reportportal_project:
required: false

env:
BASE_URL_INSTANCES: https://test.e2e.dhis2.org
NAME_PATTERN_PROD_INSTANCES: 'analytics-{version}'

concurrency:
group: e2e-prod-${{ github.workflow}}-${{ github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash

jobs:
compute-prod-versions:
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.prod-versions.outputs.versions }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Output prod version urls
id: prod-versions
uses: dhis2/action-supported-legacy-versions@v1
with:
instance-url-latest: https://test.e2e.dhis2.org/analytics-dev # can be removed if maxDHIS2Version has been specified
username: ${{ secrets.username }}
password: ${{ secrets.password }}

e2e-prod:
needs: compute-prod-versions
runs-on: ubuntu-latest
env:
CI_BUILD_ID: ${{ github.sha }}-${{ github.workflow }}-${{ github.event_name }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
PR_TITLE: ${{ github.event.pull_request.title }}
DHIS2_VERSION: ${{ matrix.versions }}
strategy:
fail-fast: false
matrix:
versions: ${{ fromJSON(needs.compute-prod-versions.outputs.versions) }}
containers: [1, 2, 3, 4]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.x
- uses: browser-actions/setup-chrome@v1
with:
chrome-version: stable
- run: |
echo "BROWSER_PATH=$(which chrome)" >> $GITHUB_ENV

- name: Compute prod instance url
id: instance-url
run: |
url=${BASE_URL_INSTANCES%/}/${NAME_PATTERN_PROD_INSTANCES/"{version}"/$version}
echo "url=$url" >> $GITHUB_OUTPUT
echo "url: $url"
env:
version: ${{ matrix.versions }}

- name: Run e2e smoke tests
uses: cypress-io/github-action@v5
with:
spec: cypress/integration/smoke.cy.js
start: yarn d2-app-scripts start
wait-on: 'http://localhost:3000'
wait-on-timeout: 300
record: false
parallel: false
browser: chrome
env:
CI: true
BROWSER: none
CYPRESS_dhis2BaseUrl: ${{ steps.instance-url.outputs.url }}
CYPRESS_dhis2InstanceVersion: ${{matrix.versions}}
CYPRESS_dhis2Username: ${{ secrets.username }}
CYPRESS_dhis2Password: ${{ secrets.password }}
CYPRESS_networkMode: live
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run e2e tests
uses: cypress-io/github-action@v5
with:
start: yarn d2-app-scripts start
wait-on: 'http://localhost:3000'
wait-on-timeout: 300
record: ${{ inputs.should_record }}
parallel: ${{ inputs.should_record }}
browser: chrome
group: ${{ inputs.should_record && format('e2e-chrome-parallel-{0}', matrix.versions) }}
ci-build-id: ${{ inputs.should_record && github.run_id }}
env:
CI: true
BROWSER: none
CYPRESS_RECORD_KEY: ${{ secrets.recordkey }}
CYPRESS_dhis2BaseUrl: ${{ steps.instance-url.outputs.url }}
CYPRESS_dhis2InstanceVersion: ${{matrix.versions}}
CYPRESS_dhis2Username: ${{ secrets.username }}
CYPRESS_dhis2Password: ${{ secrets.password }}
CYPRESS_networkMode: live
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPORTPORTAL_API_KEY: ${{ secrets.reportportal_api_key }}
REPORTPORTAL_ENDPOINT: ${{ secrets.reportportal_endpoint }}
REPORTPORTAL_PROJECT: ${{ secrets.reportportal_project }}

e2e-tests-success:
needs: e2e-prod
if: ${{ success() || failure() }}
runs-on: ubuntu-latest
steps:
- run: if [ $result != 'success' ]; then exit 1; fi;
env:
result: ${{ needs.e2e-prod.result }}
25 changes: 24 additions & 1 deletion cypress/integration/smoke.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,31 @@ import { goToStartPage } from '../helpers/startScreen.js'
import { EXTENDED_TIMEOUT } from '../support/util.js'

describe('Smoke Test', () => {
it('loads', () => {
it('app loads with correct system and user settings', () => {
cy.intercept('**userSettings**').as('userSettings')
cy.intercept('**systemSettings**').as('systemSettings')

goToStartPage()
cy.log('Check user settings')
cy.wait('@userSettings').then((interception) => {
cy.log('userSettings', interception.response.body)
expect(interception.response.body.keyUiLocale).to.equal('en')
expect(
interception.response.body.keyAnalysisDisplayProperty
).to.equal('name')
})
cy.log('Check system settings')
cy.wait('@systemSettings').then((interception) => {
cy.log('systemsettings', interception.response.body)
expect(
interception.response.body.keyAnalysisRelativePeriod
).to.equal('LAST_12_MONTHS')
expect(
interception.response.body.keyAnalysisDigitGroupSeparator
).to.equal('SPACE')
})

cy.log('Check app is loaded')
cy.contains('Getting started', EXTENDED_TIMEOUT).should('be.visible')
cy.title().should('equal', 'Line Listing | DHIS2')
})
Expand Down
Loading