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 all 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
117 changes: 117 additions & 0 deletions .github/workflows/e2e-smoke.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: 'e2e-smoke'

# 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

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

concurrency:
group: e2e-smoke-${{ 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-smoke-tests:
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]
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_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 }}

e2e-smoke-success:
needs: e2e-smoke-tests
if: ${{ success() || failure() }}
runs-on: ubuntu-latest
steps:
- run: if [ $result != 'success' ]; then exit 1; fi;
env:
result: ${{ needs.e2e-smoke-tests.result }}
12 changes: 11 additions & 1 deletion .github/workflows/verify-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,19 @@ jobs:
- name: Test
run: yarn d2-app-scripts test

call-workflow-e2e-prod:
call-workflow-e2e-smoke:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
needs: [build, lint, test, setup-matrix]
uses: ./.github/workflows/e2e-smoke.yml
with:
should_record: false
secrets:
username: ${{ secrets.CYPRESS_DHIS2_USERNAME }}
password: ${{ secrets.CYPRESS_DHIS2_PASSWORD }}

call-workflow-e2e-prod:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
needs: [call-workflow-e2e-smoke]
uses: dhis2/workflows/.github/workflows/analytics-e2e-tests-prod.yml@feat/support-hardcoded-dev-version
with:
should_record: ${{ contains(github.event.head_commit.message, '[e2e record]') || contains(join(github.event.pull_request.labels.*.name), 'e2e record')}}
Expand Down
37 changes: 36 additions & 1 deletion cypress/integration/smoke.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,52 @@ 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')
})

it('loads with visualization id', () => {
cy.intercept('**/api/*/analytics/**').as('getAnalytics')
goToAO(TEST_AO.id)

cy.wait('@getAnalytics').then((interception) => {
expect(interception.response.statusCode).to.equal(200)
expect(interception.response.body.rows).to.be.an('array')
})

cy.getBySel('titlebar', EXTENDED_TIMEOUT)
.should('be.visible')
.and('contain', TEST_AO.name)

cy.getBySel('line-list-table')
.findBySel('table-body')
.find('tr')
.its('length')
.should('be.gte', 0)
})
})
Loading