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

fix: update 'No data' handling #3408

Merged
merged 8 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@dhis2/app-runtime": "^3.11.2",
"@dhis2/app-runtime-adapter-d2": "^1.1.0",
"@dhis2/app-service-datastore": "^1.0.0-beta.3",
"@dhis2/maps-gl": "^4.0.0",
"@dhis2/maps-gl": "git+https://github.com/d2-ci/maps-gl.git#1b235a8e3fc0a7cb9b207b2353236c4e2952bffe",
"@dhis2/ui": "^9.13.0",
"@krakenjs/post-robot": "^11.0.0",
"@reportportal/agent-js-cypress": "git+https://github.com/dhis2/agent-js-cypress.git#develop",
Expand Down
2 changes: 1 addition & 1 deletion src/components/map/layers/ThematicLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class ThematicLayer extends Layer {
<div>{indicator}</div>
<div>{periodName}</div>
<div>
{i18n.t('Value')}: {value ? value : i18n.t('No data')}
{i18n.t('Value')}: {value ?? i18n.t('No data')}
</div>
{aggregationType && aggregationType !== 'DEFAULT' && (
<div>{aggregationType}</div>
Expand Down
2 changes: 2 additions & 0 deletions src/util/labels.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import i18n from '@dhis2/d2-i18n'
import {
LABEL_FONT_SIZE,
LABEL_FONT_STYLE,
Expand All @@ -20,5 +21,6 @@ export const getLabelStyle = ({
lineHeight: parseInt(fontSize, 10) * 1.2 + 'px',
color: cssColor(labelFontColor) || LABEL_FONT_COLOR,
paddingTop: '10px',
labelNoData: i18n.t('No data'),
}
}
5 changes: 2 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2246,10 +2246,9 @@
i18next "^10.3"
moment "^2.24.0"

"@dhis2/maps-gl@^4.0.0":
"@dhis2/maps-gl@git+https://github.com/d2-ci/maps-gl.git#1b235a8e3fc0a7cb9b207b2353236c4e2952bffe":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@dhis2/maps-gl/-/maps-gl-4.0.0.tgz#e97df2fbc78f787a0916224d7d54fb96b9c376db"
integrity sha512-TDEIBT6rFuEZGXnBxAqKhSmCXk3wtuCf/OrVZBKxT1qk0kHau71f3lzAXbWhYAuop8t6/DyJaIcQrUYMi1Xy3w==
resolved "git+https://github.com/d2-ci/maps-gl.git#1b235a8e3fc0a7cb9b207b2353236c4e2952bffe"
dependencies:
"@mapbox/sphericalmercator" "^1.2.0"
"@turf/area" "^6.5.0"
Expand Down
Loading