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: upgrade cypress to v12 #2276

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
247db2c
chore: nightly failing to set up cypress (#2378)
jenniferarnesen Jun 7, 2023
f8d38c9
fix(translations): sync translations from transifex (dev)
dhis2-bot Jun 8, 2023
a034f8d
docs: move docs to app (#2384)
janhenrikoverland Jun 9, 2023
4f71002
fix(translations): sync translations from transifex (dev)
dhis2-bot Jun 14, 2023
ace2539
chore(deps): bump json5 from 1.0.1 to 1.0.2 (#2200)
dependabot[bot] Jun 16, 2023
ee2469f
chore(deps): bump @dhis2/analytics from 25.1.10 to 25.1.15 (#2399)
dependabot[bot] Jun 16, 2023
2d8133a
fix(translations): sync translations from transifex (dev)
dhis2-bot Jun 17, 2023
9b952ec
fix(translations): sync translations from transifex (dev)
dhis2-bot Jun 25, 2023
2bb2dcc
chore: increase default cypress timeout to reduce test flakiness (#2456)
jenniferarnesen Jun 28, 2023
c5f67cf
chore(deps): bump @dhis2/ui from 8.13.6 to 8.13.11 (#2462)
dependabot[bot] Jun 28, 2023
afac010
chore: disable nightly scheduled test run (#2511)
jenniferarnesen Jul 4, 2023
928e2eb
chore: update Cypress dependencies
edoardo Mar 29, 2023
ae19968
fix: upgrade to Cypress 12
edoardo Mar 29, 2023
c538e8b
chore: get cypress tests running
Mohammer5 Mar 30, 2023
1eb8732
fix: add missing start-server-and-test dev dependency
edoardo Mar 30, 2023
4cd34fa
test(cypress): fix URL matching in intercept
edoardo Mar 31, 2023
e0ae441
fix: add custom command for handling iframe content
edoardo Apr 12, 2023
3776c0c
fix: modified tests to work with iframe plugins
edoardo Apr 12, 2023
97d7a7b
fix: disable Chrome security for cross origin iframes
edoardo Apr 13, 2023
244c63a
test: re-enable some filter tests
edoardo Apr 18, 2023
dd960be
chore: update cypress tooling dependencies
edoardo Jul 6, 2023
b4d677e
test: re-enable commented test
edoardo Jul 6, 2023
ac79a38
chore: align things with Cypress 12
HendrikThePendric Jul 6, 2023
d728f76
chore: empty commit to trigger e2e checks on ci
HendrikThePendric Jul 6, 2023
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
6 changes: 3 additions & 3 deletions .github/workflows/dhis2-preview-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ jobs:
runs-on: ubuntu-latest
if: "!github.event.push.repository.fork && github.actor != 'dependabot[bot]'"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14.x

- uses: c-hive/gha-yarn-cache@v1
- uses: c-hive/gha-yarn-cache@v2
- run: yarn install --frozen-lockfile

- name: Build
Expand Down
61 changes: 12 additions & 49 deletions .github/workflows/dhis2-verify-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
branches:
- 'master'
- 'dev'
tags:
- '*'

env:
GIT_AUTHOR_NAME: '@dhis2-bot'
Expand Down Expand Up @@ -73,61 +75,22 @@ jobs:
- name: Test
run: yarn d2-app-scripts test

e2e-prod:
runs-on: ubuntu-latest
needs: test
if: "!contains(github.event.head_commit.message, '[skip ci]')"

strategy:
matrix:
containers: [1, 2, 3, 4]

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.x

- uses: actions/cache@v2
id: yarn-cache
with:
path: '**/node_modules'
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: Install Cypress binary
run: yarn cypress install

- name: End-to-End tests
uses: cypress-io/github-action@v2
with:
record: true
parallel: true
start: ${{ env.SERVER_START_CMD }}
wait-on: ${{ env.SERVER_URL }}
wait-on-timeout: 300
cache-key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
group: 'e2e'
tag: ${{ github.event_name }}
env:
CI: true
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
SERVER_START_CMD: 'yarn cypress:start'
SERVER_URL: 'http://localhost:3000'
cypress_dhis2_api_stub_mode: 'DISABLED'
REACT_APP_DHIS2_BASE_URL: ${{ secrets.CYPRESS_DHIS2_BASE_URL_40 }}
cypress_dhis2_base_url: ${{ secrets.CYPRESS_DHIS2_BASE_URL_40}}
cypress_dhis2_username: ${{ secrets.CYPRESS_DHIS2_USERNAME }}
cypress_dhis2_password: ${{ secrets.CYPRESS_DHIS2_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
call-workflow-e2e-prod:
needs: [build, lint, test]
uses: dhis2/line-listing-app/.github/workflows/e2e-prod.yml@master
secrets:
baseurl: ${{ secrets.CYPRESS_DHIS2_BASE_URL_DEV }}
username: ${{ secrets.CYPRESS_DHIS2_USERNAME }}
password: ${{ secrets.CYPRESS_DHIS2_PASSWORD }}
recordkey: ${{ secrets.CYPRESS_RECORD_KEY }}

release:
runs-on: ubuntu-latest
needs: e2e-prod
needs: call-workflow-e2e-prod
if: |
!github.event.push.repository.fork &&
github.actor != 'dependabot[bot]' &&
github.ref == 'refs/heads/master'
github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v3
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/dhis2-verify-commits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:
lint-pr-title:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: c-hive/gha-yarn-cache@v1
- uses: actions/checkout@v3
- uses: c-hive/gha-yarn-cache@v2
- run: yarn install --frozen-lockfile
- id: commitlint
run: echo ::set-output name=config_path::$(node -e "process.stdout.write(require('@dhis2/cli-style').config.commitlint)")
Expand All @@ -20,10 +20,10 @@ jobs:
lint-commits:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: c-hive/gha-yarn-cache@v1
- uses: c-hive/gha-yarn-cache@v2
- run: yarn install --frozen-lockfile
- id: commitlint
run: echo ::set-output name=config_path::$(node -e "process.stdout.write(require('@dhis2/cli-style').config.commitlint)")
Expand Down
19 changes: 6 additions & 13 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: 'dhis2: nightly'

# This workflow runs the e2e tests on the default branch against dev at 5:10am M-F
# This workflow runs the e2e tests on the default branch against dev

on:
schedule:
- cron: '10 5 * * 1-5'
# schedule:
# - cron: '10 4 * * 2'
workflow_dispatch:

concurrency:
group: ${{ github.workflow}}-${{ github.ref }}
Expand All @@ -28,14 +29,8 @@ jobs:
with:
node-version: 18.x

- uses: actions/cache@v2
id: yarn-cache
with:
path: '**/node_modules'
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: Install Cypress binary
run: yarn cypress install
- name: Install
run: yarn install --frozen-lockfile

- name: End-to-End tests
uses: cypress-io/github-action@v2
Expand All @@ -45,13 +40,11 @@ jobs:
start: ${{ env.SERVER_START_CMD }}
wait-on: ${{ env.SERVER_URL }}
wait-on-timeout: 300
cache-key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
group: 'e2e'
tag: ${{ github.event_name }}
env:
CI: true
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
SERVER_START_CMD: 'yarn cypress:start'
SERVER_URL: 'http://localhost:3000'
cypress_dhis2_api_stub_mode: 'DISABLED'
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# testing
/coverage

# documentation
docs/*

# misc
.DS_Store
.env*.local
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [100.0.1](https://github.com/dhis2/dashboard-app/compare/v100.0.0...v100.0.1) (2023-06-12)


### Bug Fixes

* **translations:** sync translations from transifex (dev) ([5b0b3b6](https://github.com/dhis2/dashboard-app/commit/5b0b3b64227229415cbd6efda23bdb2cf13e3305))

# [100.0.0](https://github.com/dhis2/dashboard-app/compare/v99.99.9...v100.0.0) (2023-06-06)


Expand Down
3 changes: 0 additions & 3 deletions cypress-cucumber-preprocessor.config.js

This file was deleted.

67 changes: 67 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
const {
addCucumberPreprocessorPlugin,
} = require('@badeball/cypress-cucumber-preprocessor')
const createEsbuildPlugin = require('@badeball/cypress-cucumber-preprocessor/esbuild')
const createBundler = require('@bahmutov/cypress-esbuild-preprocessor')
const { chromeAllowXSiteCookies } = require('@dhis2/cypress-plugins')
const { defineConfig } = require('cypress')
const {
excludeByVersionTags,
} = require('./cypress/plugins/excludeByVersionTags.js')

async function setupNodeEvents(on, config) {
await addCucumberPreprocessorPlugin(on, config)
chromeAllowXSiteCookies(on, config)
excludeByVersionTags(on, config)

if (!config.env.dhis2InstanceVersion) {
throw new Error(
'dhis2InstanceVersion is missing. Check the README for more information.'
)
}

on(
'file:preprocessor',
createBundler({
plugins: [createEsbuildPlugin.default(config)],
})
)

return config
}

module.exports = defineConfig({
projectId: '5fk191',
chromeWebSecurity: false,
e2e: {
setupNodeEvents,
baseUrl: 'http://localhost:3000',
specPattern: 'cypress/e2e/**/*.feature',
viewportWidth: 1280,
viewportHeight: 800,
defaultCommandTimeout: 15000,
/* Globally disable test isolation because the test suite
* contains many tests with sequential steps */
testIsolation: false,
// Record video
video: true,
/* Only compress and upload videos for failures.
* This will save execution time and reduce the risk
* out-of-memory issues on the CI machine */
videoUploadOnPasses: false,
// Enabled to reduce the risk of out-of-memory issues
experimentalMemoryManagement: true,
// Set to a low number to reduce the risk of out-of-memory issues
numTestsKeptInMemory: 5,
/* When allowing 1 retry on CI, the test suite will pass if
* it's flaky. And/but we also get to identify flaky tests on the
* Cypress Dashboard. */
retries: {
runMode: 1,
openMode: 0,
},
},
env: {
networkMode: 'live',
},
})
8 changes: 0 additions & 8 deletions cypress.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { When } from 'cypress-cucumber-preprocessor/steps'
import { When } from '@badeball/cypress-cucumber-preprocessor'

When('dashboard items are added', () => {
cy.get('[data-test="item-search"]').click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { When } from 'cypress-cucumber-preprocessor/steps'
import { When } from '@badeball/cypress-cucumber-preprocessor'
import { confirmActionDialogSel } from '../../../elements/editDashboard.js'

When('I confirm I want to discard changes', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { When } from 'cypress-cucumber-preprocessor/steps'
import { When } from '@badeball/cypress-cucumber-preprocessor'
import { clickEditActionButton } from '../../../elements/editDashboard.js'

When('I click Exit without saving', () => {
Expand Down
14 changes: 14 additions & 0 deletions cypress/e2e/common/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import './before_each_visit_root.js'
import './edit/add_dashboard_items.js'
import './edit/confirm_discard_changes.js'
import './edit/exit_without_saving.js'
import './view/add_a_FILTERTYPE_filter.js'
import './view/choose_to_edit_dashboard.js'
import './view/click_on_the_FILTERTYPE_filter_badge.js'
import './view/exit_print_layout.js'
import './view/open_print_layout.js'
import './view/open_the_SL_dashboard.js'
import './view/print_layout_displays.js'
import './view/start_new_dashboard.js'
import './view/the_dashboard_description_is_(not)_displayed.js'
import './view/SL_dashboard_displays_in_view_mode.js'
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { Then } from 'cypress-cucumber-preprocessor/steps'
import { Then } from '@badeball/cypress-cucumber-preprocessor'
import { dashboards } from '../../../assets/backends/index.js'
// import { chartSel } from '../../../elements/dashboardItem.js'
import { gridItemSel, chartSel } from '../../../elements/dashboardItem.js'
import { dashboardTitleSel } from '../../../elements/viewDashboard.js'
// import { EXTENDED_TIMEOUT } from '../../../support/utils.js'
import { EXTENDED_TIMEOUT } from '../../../support/utils.js'

Then('the {string} dashboard displays in view mode', (title) => {
cy.location().should((loc) => {
expect(loc.hash).to.equal(dashboards[title].route)
})

cy.get(dashboardTitleSel).should('be.visible').and('contain', title)
// FIXME
// cy.get(chartSel, EXTENDED_TIMEOUT).should('exist')

cy.get(gridItemSel)
.first()
.getIframeBody()
.find(chartSel, EXTENDED_TIMEOUT)
.should('exist')
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { When } from 'cypress-cucumber-preprocessor/steps'
import { When } from '@badeball/cypress-cucumber-preprocessor'
import {
unselectedItemsSel,
filterDimensionsPanelSel,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { When, Then } from 'cypress-cucumber-preprocessor/steps'
import { When, Then } from '@badeball/cypress-cucumber-preprocessor'
import { titleInputSel } from '../../../elements/editDashboard.js'
import { titleBarSel } from '../../../elements/viewDashboard.js'
import { EXTENDED_TIMEOUT } from '../../../support/utils.js'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { When } from 'cypress-cucumber-preprocessor/steps'
import { When } from '@badeball/cypress-cucumber-preprocessor'
import { filterBadgeSel } from '../../../elements/dashboardFilter.js'

When('I click on the {string} filter badge', (filterName) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { When } from 'cypress-cucumber-preprocessor/steps'
import { When } from '@badeball/cypress-cucumber-preprocessor'
import { dashboardTitleSel } from '../../../elements/viewDashboard.js'

When('I click to exit print preview', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { When } from 'cypress-cucumber-preprocessor/steps'
import { When } from '@badeball/cypress-cucumber-preprocessor'
import { clickViewActionButton } from '../../../elements/viewDashboard.js'

When('I click to preview the print layout', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Given } from 'cypress-cucumber-preprocessor/steps'
import { Given } from '@badeball/cypress-cucumber-preprocessor'
import { dashboards } from '../../../assets/backends/index.js'
// import { chartSel } from '../../../elements/dashboardItem.js'
import { gridItemSel, chartSel } from '../../../elements/dashboardItem.js'
import {
dashboardTitleSel,
dashboardChipSel,
Expand All @@ -15,7 +15,10 @@ Given('I open the {string} dashboard', (title) => {
})

cy.get(dashboardTitleSel).should('be.visible').and('contain', title)
// FIXME
// cy.get(chartSel, EXTENDED_TIMEOUT).should('exist')
cy.wait(3000) // eslint-disable-line cypress/no-unnecessary-waiting

cy.get(`${gridItemSel}.VISUALIZATION`)
.first()
.getIframeBody()
.find(chartSel, EXTENDED_TIMEOUT)
.should('exist')
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Then } from 'cypress-cucumber-preprocessor/steps'
import { Then } from '@badeball/cypress-cucumber-preprocessor'
import { dashboards } from '../../../assets/backends/sierraLeone_236.js'

Then('the print layout displays for {string} dashboard', (title) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Given } from 'cypress-cucumber-preprocessor/steps'
import { Given } from '@badeball/cypress-cucumber-preprocessor'
import { newButtonSel } from '../../../elements/viewDashboard.js'
import { EXTENDED_TIMEOUT } from '../../../support/utils.js'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Then } from 'cypress-cucumber-preprocessor/steps'
import { Then } from '@badeball/cypress-cucumber-preprocessor'
import { dashboardDescriptionSel } from '../../../elements/viewDashboard.js'

Then('the dashboard description is not displayed', () => {
Expand Down
Loading
Loading