Skip to content

Commit

Permalink
chore: fix cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BRaimbault committed Dec 20, 2024
1 parent c0d7028 commit 91a69bb
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 45 deletions.
2 changes: 2 additions & 0 deletions cypress/elements/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export class Layer {
}

typeStartDate(dateString) {
cy.getByDataTest('calendar-clear-button').eq(0).click()
cy.getByDataTest('start-date-input-content')
.find('input')
.type(dateString)
Expand All @@ -74,6 +75,7 @@ export class Layer {
}

typeEndDate(dateString) {
cy.getByDataTest('calendar-clear-button').eq(1).click()
cy.getByDataTest('end-date-input-content')
.find('input')
.type(dateString)
Expand Down
46 changes: 23 additions & 23 deletions cypress/integration/layers/eventlayer.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,33 @@ import { EXTENDED_TIMEOUT } from '../../support/util.js'

context('Event Layers', () => {
beforeEach(() => {
cy.visit('/', EXTENDED_TIMEOUT)
cy.visit('/')
})

const Layer = new EventLayer()

it('adds an event layer and applies style for boolean data element', () => {
Layer.openDialog('Events')
.selectProgram('E2E program')
.validateStage('Stage 1 - Repeatable')
.selectTab('Style')

cy.getByDataTest('style-by-data-element-select').click()

cy.getByDataTest('dhis2-uicore-singleselectoption')
.contains('E2E - Yes/no')
.click()

cy.getByDataTest('dhis2-uicore-modalactions')
.contains('Add layer')
.click()

Layer.validateDialogClosed(true)

Layer.validateCardTitle('Stage 1 - Repeatable')
Layer.validateCardItems(['Yes', 'No', 'Not set'])
})

it('shows error if no program selected', () => {
Layer.openDialog('Events').addToMap()

Expand All @@ -31,28 +53,6 @@ context('Event Layers', () => {
Layer.validateCardItems(['Event'])
})

it('adds an event layer and applies style for boolean data element', () => {
Layer.openDialog('Events')
.selectProgram('E2E program')
.validateStage('Stage 1 - Repeatable')
.selectTab('Style')

cy.getByDataTest('style-by-data-element-select').click()

cy.getByDataTest('dhis2-uicore-singleselectoption')
.contains('E2E - Yes/no')
.click()

cy.getByDataTest('dhis2-uicore-modalactions')
.contains('Add layer')
.click()

Layer.validateDialogClosed(true)

Layer.validateCardTitle('Stage 1 - Repeatable')
Layer.validateCardItems(['Yes', 'No', 'Not set'])
})

it('opens an event popup', () => {
Layer.openDialog('Events')
.selectProgram('Inpatient morbidity and mortality')
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/layers/multilayers.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('Multiple Layers', () => {
.selectIndicatorGroup('ANC')
.selectIndicator(INDICATOR_NAME)
.selectTab('Period')
.selectPeriodType('Yearly')
.selectPeriodType('YEARLY')
.selectTab('Org Units')
.selectOu('Sierra Leone')
.selectOuLevel('District')
Expand Down
42 changes: 21 additions & 21 deletions cypress/integration/layers/telayer.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,11 @@ import { EXTENDED_TIMEOUT } from '../../support/util.js'

describe('Tracked Entity Layers', () => {
beforeEach(() => {
cy.visit('/', EXTENDED_TIMEOUT)
cy.visit('/')
})

const Layer = new TeLayer()

it('adds a tracked entity layer', () => {
Layer.openDialog('Tracked entities')
.selectTab('Data')
.selectTeType('Malaria Entity')
.selectTeProgram(
'Malaria case diagnosis, treatment and investigation'
)
.selectTab('Org Units')
.selectOu('Bombali')
.selectOu('Bo')
.addToMap()

Layer.validateDialogClosed(true)

Layer.validateCardTitle(
'Malaria case diagnosis, treatment and investigation'
)
Layer.validateCardItems(['Malaria Entity'])
})

it('opens a tracked entity layer popup', () => {
Layer.openDialog('Tracked entities')
.selectTab('Data')
Expand Down Expand Up @@ -80,4 +60,24 @@ describe('Tracked Entity Layers', () => {
Layer.validateCardTitle('Malaria focus investigation')
Layer.validateCardItems(['Focus area'])
})

it('adds a tracked entity layer', () => {
Layer.openDialog('Tracked entities')
.selectTab('Data')
.selectTeType('Malaria Entity')
.selectTeProgram(
'Malaria case diagnosis, treatment and investigation'
)
.selectTab('Org Units')
.selectOu('Bombali')
.selectOu('Bo')
.addToMap()

Layer.validateDialogClosed(true)

Layer.validateCardTitle(
'Malaria case diagnosis, treatment and investigation'
)
Layer.validateCardItems(['Malaria Entity'])
})
})
2 changes: 2 additions & 0 deletions src/components/periods/StartEndDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ const StartEndDate = (props) => {
placeholder="YYYY-MM-DD"
dataTest="start-date-input"
strictValidation={true}
clearable={true}
/>
<div className={styles.icon}>
<IconArrowRight16 color={colors.grey500} />
Expand All @@ -152,6 +153,7 @@ const StartEndDate = (props) => {
placeholder="YYYY-MM-DD"
dataTest="end-date-input"
strictValidation={true}
clearable={true}
/>
</div>
{errorText && (
Expand Down

0 comments on commit 91a69bb

Please sign in to comment.