Skip to content

Commit

Permalink
chore: add cypress test
Browse files Browse the repository at this point in the history
  • Loading branch information
BRaimbault committed Nov 22, 2024
1 parent 6af6652 commit 2f9cf8e
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 1 deletion.
13 changes: 13 additions & 0 deletions cypress/elements/thematic_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,23 @@ export class ThematicLayer extends Layer {
return this
}

selectRelativePeriod(period) {
cy.get('[data-test="relative-period-select"]').click()
cy.contains(period).click()

return this
}

selectPeriodType(periodType) {
cy.get('[data-test="periodtypeselect"]').click()
cy.contains(periodType).click()

return this
}

selectIncludeNoDataOU() {
cy.contains('Include org units with no data').click()

return this
}
}
73 changes: 72 additions & 1 deletion cypress/integration/layers/thematiclayer.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import {
expectContextMenuOptions,
} from '../../elements/map_context_menu.js'
import { ThematicLayer } from '../../elements/thematic_layer.js'
import { CURRENT_YEAR, getApiBaseUrl } from '../../support/util.js'
import {
CURRENT_YEAR,
getApiBaseUrl,
EXTENDED_TIMEOUT,
} from '../../support/util.js'

const INDICATOR_NAME = 'VCCT post-test counselling rate'

Expand Down Expand Up @@ -95,6 +99,73 @@ context('Thematic Layers', () => {
getMaps().should('have.length', 1)
})

it('opens a thematic layer popup with data and nodata', () => {
Layer.openDialog('Thematic')
.selectIndicatorGroup('Stock')
.selectIndicator('BCG Stock PHU')
.selectTab('Period')
.selectRelativePeriod('This month')
.selectTab('Style')
.selectIncludeNoDataOU()
.selectTab('Org Units')
.unselectOuLevel('District')
.selectOuLevel('Facility')

cy.getByDataTest('org-unit-tree-node')
.contains('Western Area')
.parents('[data-test="org-unit-tree-node"]')
.first()
.within(() => {
cy.getByDataTest('org-unit-tree-node-toggle').click()
})

cy.getByDataTest('org-unit-tree-node')
.contains('Rural Western Area')
.parents('[data-test="org-unit-tree-node"]')
.first()
.within(() => {
cy.getByDataTest('org-unit-tree-node-toggle').click()
})

// Value: 0
cy.getByDataTest('org-unit-tree-node').contains('Tokeh MCHP').click()

cy.getByDataTest('layeredit-addbtn').click()

Layer.validateDialogClosed(true)

cy.wait(5000) // eslint-disable-line cypress/no-unnecessary-waiting
cy.get('#dhis2-map-container')
.findByDataTest('dhis2-uicore-componentcover', EXTENDED_TIMEOUT)
.should('not.exist')
cy.get('.dhis2-map').click('center') //Click somewhere on the map

cy.get('.maplibregl-popup').contains('Value: 0').should('be.visible')

// Value: No data
cy.getByDataTest('layer-edit-button').click()
Layer.selectTab('Org Units')

cy.getByDataTest('org-unit-tree-node').contains('Tokeh MCHP').click()
cy.getByDataTest('org-unit-tree-node')
.contains('Lakka Hospital')
.click()

cy.getByDataTest('layeredit-addbtn').click()

Layer.validateDialogClosed(true)

cy.wait(5000) // eslint-disable-line cypress/no-unnecessary-waiting
cy.get('#dhis2-map-container')
.findByDataTest('dhis2-uicore-componentcover', EXTENDED_TIMEOUT)
.should('not.exist')
cy.get('.dhis2-map').click('center') //Click somewhere on the map

cy.get('.maplibregl-popup')
.contains('Value: No data')
.should('be.visible')
})

it('adds a thematic layer with split view period', () => {
Layer.openDialog('Thematic')
.selectIndicatorGroup('ANC')
Expand Down

0 comments on commit 2f9cf8e

Please sign in to comment.