Skip to content

Commit

Permalink
chore: clean up cypress folder (#2687)
Browse files Browse the repository at this point in the history
None of the server code is in use.
  • Loading branch information
jenniferarnesen authored and edoardo committed Oct 9, 2023
1 parent 51e3dde commit eecbceb
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 282 deletions.
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ CYPRESS_DHIS2_PASSWORD=district

The following commands can be used to run the tests:

| Command | Backend | Environment | Tests |
| ------------------- | :--------: | ----------: | -----------: |
| `yarn cy:open-live` | API server | Cypress UI | All |
| `yarn cy:run-live` | API server | Headless | All |
| `yarn cy:open-stub` | Fixtures | Cypress UI | Non-mutating |
| `yarn cy:run-stub` | Fixtures | Headless | Non-mutating |
| Comman | Backend | Environment | Tests |
| -------------- | :--------: | ----------: | ----: |
| `yarn cy:open` | API server | Cypress UI | All |
| `yarn cy:run` | API server | Headless | All |

### `yarn test`

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { When, Then } from 'cypress-cucumber-preprocessor/steps'
import { clickViewActionButton } from '../../../elements/viewDashboard.js'
import { getApiBaseUrl } from '../../../support/server/utils.js'
import { getApiBaseUrl } from '../../../support/utils.js'

const SHOW_DESC_RESP_CODE_SUCCESS = 201
const SHOW_DESC_RESP_CODE_FAIL = 409
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import {
dashboardDescriptionSel,
clickViewActionButton,
} from '../../../elements/viewDashboard.js'
import { getApiBaseUrl } from '../../../support/server/utils.js'
import { EXTENDED_TIMEOUT } from '../../../support/utils.js'
import { getApiBaseUrl, EXTENDED_TIMEOUT } from '../../../support/utils.js'

let norwegianTitle = ''
let norwegianDesc = ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {
dashboardChipSel,
dashboardTitleSel,
} from '../../../elements/viewDashboard.js'
import { getApiBaseUrl } from '../../../support/server/utils.js'
import {
EXTENDED_TIMEOUT,
createDashboardTitle,
getApiBaseUrl,
} from '../../../support/utils.js'

const TEST_DASHBOARD_TITLE = createDashboardTitle('af')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import {
dashboardsBarContainerSel,
showMoreLessSel,
} from '../../../elements/viewDashboard.js'
import { getApiBaseUrl } from '../../../support/server/utils.js'
import { EXTENDED_TIMEOUT } from '../../../support/utils.js'
import { getApiBaseUrl, EXTENDED_TIMEOUT } from '../../../support/utils.js'

const MIN_DASHBOARDS_BAR_HEIGHT = 71
const MAX_DASHBOARDS_BAR_HEIGHT = 431
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { When, Then } from 'cypress-cucumber-preprocessor/steps'
import { getApiBaseUrl } from '../../../support/server/utils.js'
import { getApiBaseUrl } from '../../../support/utils.js'

// Error scenario

Expand Down
9 changes: 1 addition & 8 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import { enableAutoLogin } from '@dhis2/cypress-commands'
import { enableNetworkShim } from './server/index.js'
import { getDefaultMode, isStubMode } from './server/utils.js'
import './commands.js'

enableNetworkShim()

if (!isStubMode(getDefaultMode())) {
// log in if using a live backend
enableAutoLogin()
}
enableAutoLogin()

const resizeObserverLoopErrRe = /^[^(ResizeObserver loop limit exceeded)]/
Cypress.on('uncaught:exception', (err) => {
Expand Down
157 changes: 0 additions & 157 deletions cypress/support/server/Networkshim.js

This file was deleted.

9 changes: 0 additions & 9 deletions cypress/support/server/constants.js

This file was deleted.

36 changes: 0 additions & 36 deletions cypress/support/server/enableNetworkShim.js

This file was deleted.

1 change: 0 additions & 1 deletion cypress/support/server/index.js

This file was deleted.

37 changes: 0 additions & 37 deletions cypress/support/server/utils.js

This file was deleted.

16 changes: 0 additions & 16 deletions cypress/support/server/visitWithUnfetchOverwriteFn.js

This file was deleted.

12 changes: 12 additions & 0 deletions cypress/support/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
export const EXTENDED_TIMEOUT = { timeout: 25000 }

export const getApiBaseUrl = () => {
const baseUrl = Cypress.env('dhis2_base_url') || ''

if (!baseUrl) {
throw new Error(
'No `dhis2_base_url` found. Please make sure to add it to `cypress.env.json`'
)
}

return baseUrl
}

export const goOffline = () => {
cy.log('**go offline**')
.then(() => {
Expand Down
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,8 @@
"validate-push": "CI=true yarn test",
"postinstall": "patch-package",
"cypress:start": "BROWSER=none yarn start",
"cy:open-live": "cypress_dhis2_api_stub_mode=DISABLED d2-utils-cypress open --appStart 'yarn cypress:start'",
"cy:run-live": "cypress_dhis2_api_stub_mode=DISABLED d2-utils-cypress run --appStart 'yarn cypress:start'",
"cy:open-stub": "cypress_dhis2_api_stub_mode=STUB d2-utils-cypress open --appStart 'yarn cypress:start'",
"cy:run-stub": "cypress_dhis2_api_stub_mode=STUB d2-utils-cypress run --tags '@nonmutating' --appStart 'yarn cypress:start' --record",
"cy:capture": "cypress_dhis2_api_stub_mode=CAPTURE yarn d2-utils-cypress run --appStart 'yarn cypress:start'"
"cy:open": "d2-utils-cypress open --appStart 'yarn cypress:start'",
"cy:run": "d2-utils-cypress run --appStart 'yarn cypress:start'"
},
"devDependencies": {
"@dhis2/cli-app-scripts": "^10.4.0-alpha.2",
Expand Down

0 comments on commit eecbceb

Please sign in to comment.