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: cypress 13 upgrade #3040

Merged
merged 46 commits into from
Aug 2, 2024
Merged
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
7200676
chore: upgrade and add needed cypress dependencies
jenniferarnesen Jul 24, 2024
ff89aaf
chore: move files to e2e and move to cypress.config.js
jenniferarnesen Jul 24, 2024
53940e6
chore: add cypress as a dev dependency
jenniferarnesen Jul 24, 2024
5b7662a
chore: add smoke test and disable some before fns for now
jenniferarnesen Jul 24, 2024
ab4e41f
chore: move cucumber config to own file
jenniferarnesen Jul 24, 2024
2ceac87
chore: use enableAutoLogin
jenniferarnesen Jul 24, 2024
cf11a01
chore: beforeEach running on everything and the offline tests are not…
jenniferarnesen Jul 24, 2024
cbf8806
chore: increase extended timeout
jenniferarnesen Jul 24, 2024
2ae06ec
chore: node version
jenniferarnesen Jul 24, 2024
cf0604f
chore: wrong test file path
jenniferarnesen Jul 24, 2024
9ea19ee
chore: cypress ci changes
jenniferarnesen Jul 24, 2024
2927f0c
chore: upgrade cypress-io/github-action
jenniferarnesen Jul 24, 2024
ef17af6
chore: username and password for ci
jenniferarnesen Jul 24, 2024
f2bcb0e
chore: need instance version
jenniferarnesen Jul 24, 2024
931cc35
chore: rename duplicate step
jenniferarnesen Jul 24, 2024
d233958
chore: another duplicated step
jenniferarnesen Jul 24, 2024
8951bdf
chore: syntax error
jenniferarnesen Jul 24, 2024
4211115
chore: rename duplicated steps
jenniferarnesen Jul 24, 2024
e4a75f7
chore: more duplicated steps
jenniferarnesen Jul 24, 2024
70a1871
chore: lint
jenniferarnesen Jul 24, 2024
3a4d4d8
chore: another duplicated step
jenniferarnesen Jul 25, 2024
f1c9419
chore: more duplicate steps
jenniferarnesen Jul 25, 2024
71af89d
chore: minor change to readme [e2e record]
jenniferarnesen Jul 25, 2024
1172ce7
chore: flatten test file structure
jenniferarnesen Jul 25, 2024
4d8483a
chore: more little errors in the tests
jenniferarnesen Jul 25, 2024
9c5ce56
chore: tweak trying to get tests to pass
jenniferarnesen Jul 25, 2024
1ff5f5b
chore: disable check for now
jenniferarnesen Jul 25, 2024
68bc9ee
chore: break up chain and wait
jenniferarnesen Jul 25, 2024
4f3b011
chore: disable test or checks that were previously disabled
jenniferarnesen Jul 25, 2024
af4ae11
chore: add FIXMEs back in
jenniferarnesen Jul 25, 2024
d44534f
chore: temp disable responsive tests
jenniferarnesen Jul 25, 2024
c6995c7
chore: re-enable 1 test
jenniferarnesen Jul 25, 2024
1de7b5f
chore: enable more steps
jenniferarnesen Jul 25, 2024
ee14f75
chore: try without all the cookie handling
jenniferarnesen Jul 25, 2024
ce49842
chore: restore
jenniferarnesen Jul 25, 2024
3729588
chore: enable rest of test
jenniferarnesen Jul 25, 2024
634d41f
chore: enable part of next resp test
jenniferarnesen Jul 26, 2024
33cc7ba
chore: enable rest of test
jenniferarnesen Jul 26, 2024
f34dfe4
chore: enable next test
jenniferarnesen Jul 26, 2024
442f680
chore: test tweak
jenniferarnesen Jul 26, 2024
1fb90a3
chore: enable more tests
jenniferarnesen Jul 26, 2024
51be6c0
chore: try enabling check on iframe
jenniferarnesen Jul 26, 2024
0523454
chore: purposely break test
jenniferarnesen Jul 26, 2024
4d69347
chore: unbreak test
jenniferarnesen Jul 29, 2024
2f32080
chore: try shared e2e workflow
jenniferarnesen Jul 30, 2024
b21333b
chore: remove commented code and unneeded devDep and update readme
jenniferarnesen Aug 1, 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
Prev Previous commit
Next Next commit
chore: move files to e2e and move to cypress.config.js
jenniferarnesen committed Jul 24, 2024
commit ff89aaf100e74664d014cef3d8216e95f03ac8fa
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',
},
})
9 changes: 0 additions & 9 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()
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', () => {
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', () => {
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,18 @@
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,
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'
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) => {
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', () => {
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', () => {
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,
@@ -15,7 +15,9 @@ 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) => {
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'

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', () => {
Original file line number Diff line number Diff line change
@@ -65,13 +65,12 @@ Feature: Creating, editing and deleting dashboard
# When I click to hide the description
# Then the dashboard description is not displayed

# FIXME
# @nonmutating
# Scenario: I move an item on a dashboard
# Given I open existing dashboard
# When I choose to edit dashboard
# # And the chart item is displayed
# Then no analytics requests are made when item is moved
@nonmutating
Scenario: I move an item on a dashboard
Given I open existing dashboard
When I choose to edit dashboard
And the chart item is displayed
Then no analytics requests are made when item is moved

# @mutating
# Scenario: I add translations to a dashboard and save dashboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps'
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor'
import {
gridItemSel,
// chartSel,
// chartSubtitleSel,
chartSel,
chartSubtitleSel,
} from '../../../elements/dashboardItem.js'
import {
confirmActionDialogSel,
@@ -152,10 +152,13 @@ Then('the dashboard is deleted and first starred dashboard displayed', () => {
Scenario: I move an item on a dashboard
*/

// FIXME
// Then('the chart item is displayed', () => {
// cy.get(chartSel, EXTENDED_TIMEOUT).should('exist')
// })
Then('the chart item is displayed', () => {
cy.get(`${gridItemSel}.VISUALIZATION`)
.first()
.getIframeBody()
.find(chartSel, EXTENDED_TIMEOUT)
.should('exist')
})

Then('no analytics requests are made when item is moved', () => {
const WRONG_SUBTITLE = 'WRONG_SUBTITLE'
@@ -175,8 +178,10 @@ Then('no analytics requests are made when item is moved', () => {
.trigger('mousemove', { clientX: 400 })
.trigger('mouseup')

// FIXME
// cy.get(chartSubtitleSel, EXTENDED_TIMEOUT)
// .contains(WRONG_SUBTITLE)
// .should('not.exist')
cy.get(gridItemSel)
.first()
.getIframeBody()
.find(chartSubtitleSel, EXTENDED_TIMEOUT)
.contains(WRONG_SUBTITLE)
.should('not.exist')
})
1 change: 1 addition & 0 deletions cypress/e2e/edit/edit_dashboard/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
'../../common/index.js'
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 { getSharingDialogUserSearch } from '../../../elements/sharingDialog.js'
import { dashboardTitleSel } from '../../../elements/viewDashboard.js'
import { EXTENDED_TIMEOUT } from '../../../support/utils.js'
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 { clickViewActionButton } from '../../../elements/viewDashboard.js'
import { getApiBaseUrl } from '../../../support/utils.js'

@@ -21,7 +21,7 @@ before(() => {
})

When('I click to show description', () => {
cy.intercept('PUT', 'userDataStore/dashboard/showDescription').as(
cy.intercept('PUT', '**/userDataStore/dashboard/showDescription').as(
'toggleDescription'
)

@@ -44,7 +44,7 @@ When('I click to hide the description', () => {

// Error scenario
When('clicking to show description fails', () => {
cy.intercept('PUT', 'userDataStore/dashboard/showDescription', {
cy.intercept('PUT', '**/userDataStore/dashboard/showDescription', {
statusCode: RESP_CODE_FAIL,
}).as('showDescriptionFails')

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 {
starSel,
dashboardStarredSel,
@@ -10,14 +10,14 @@ import { TEST_DASHBOARD_TITLE } from './edit_dashboard.js'

// Scenario: I star the dashboard
When('I click to star the dashboard', () => {
cy.intercept('POST', `/favorite`).as('starDashboard')
cy.intercept('POST', '**/favorite').as('starDashboard')

cy.get(starSel).click()
cy.wait('@starDashboard').its('response.statusCode').should('eq', 200)
})

When('I click to unstar the dashboard', () => {
cy.intercept('DELETE', `/favorite`).as('unstarDashboard')
cy.intercept('DELETE', '**/favorite').as('unstarDashboard')

cy.get(starSel).click()
cy.wait('@unstarDashboard').its('response.statusCode').should('eq', 200)
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 { clickEditActionButton } from '../../../elements/editDashboard.js'
import {
dashboardTitleSel,
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { When } from 'cypress-cucumber-preprocessor/steps'
import { When } from '@badeball/cypress-cucumber-preprocessor'
import {
confirmActionDialogSel,
clickEditActionButton,
} from '../../../elements/editDashboard.js'

When('A 500 error is thrown when I delete the dashboard', () => {
cy.intercept('DELETE', '/dashboards', { statusCode: 500 })
cy.intercept('DELETE', '**/dashboards/*', { statusCode: 500 })
clickEditActionButton('Delete')
cy.get(confirmActionDialogSel).find('button').contains('Delete').click()
})
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { When, Then } from 'cypress-cucumber-preprocessor/steps'
import { When, Then } from '@badeball/cypress-cucumber-preprocessor'
import { clickEditActionButton } from '../../../elements/editDashboard.js'

When("I save dashboard that I don't have access to save", () => {
cy.intercept('PUT', '/dashboards', { statusCode: 409 })
cy.intercept('PUT', '**/dashboards/*', { statusCode: 409 })
clickEditActionButton('Save changes')
})
Then('I remain in edit mode and error message is displayed', () => {
@@ -14,6 +14,6 @@ Then('I remain in edit mode and error message is displayed', () => {
})

When('A 500 error is thrown when I save the dashboard', () => {
cy.intercept('PUT', '/dashboards', { statusCode: 500 })
cy.intercept('PUT', '**/dashboards/*', { statusCode: 500 })
clickEditActionButton('Save changes')
})
1 change: 1 addition & 0 deletions cypress/e2e/edit/edit_errors/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
'../../common/index.js'
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps'
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor'
import { filterDimensionsPanelSel } from '../../../elements/dashboardFilter.js'
import {
titleInputSel,
1 change: 1 addition & 0 deletions cypress/e2e/edit/filter_restrict/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
'../../common/index.js'
Original file line number Diff line number Diff line change
@@ -36,4 +36,4 @@ Feature: Dashboard filter
When I choose to edit dashboard
And I choose to delete dashboard
When I confirm delete
Then different dashboard displays in view mode
Then different dashboard displays in view mode
Loading
Loading