Skip to content

Commit

Permalink
fix: include program, programStage, trackedEntityType in map request (#…
Browse files Browse the repository at this point in the history
…2011)

Fixes: https://jira.dhis2.org/browse/DHIS2-11924

Include program, programStage, and trackedEntityType in the map request. This information is needed for the map legend.
  • Loading branch information
jenniferarnesen authored Oct 6, 2021
1 parent c631fa6 commit 0d96c84
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 8 deletions.
13 changes: 11 additions & 2 deletions cypress/assets/backends/sierraLeone_236.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ export const dashboards = {
},
},
},
'Cases Malaria': {
id: 'JW7RlN5xafN',
route: '#/JW7RlN5xafN',
items: {
map: {
name: 'Malaria: Cases <5y female Pujehun this year events',
itemUid: 'HQp9BAUG9v8',
},
},
},
Delivery: {
id: 'iMnYyBfSxmM',
route: '#/iMnYyBfSxmM',
Expand All @@ -26,8 +36,7 @@ export const dashboards = {
itemUid: 'qXsjttMYuoZ',
},
map: {
name:
'Delivery: PHU delivery rate (by pop) by chiefdom last year',
name: 'Delivery: PHU delivery rate (by pop) by chiefdom last year',
itemUid: 'G3EtzSWNP9o',
},
},
Expand Down
6 changes: 6 additions & 0 deletions cypress/integration/view/view_dashboard.feature
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ Feature: Viewing dashboards
When I toggle show more dashboards
Then the control bar should be expanded to full height

@mutating
Scenario: Maps with tracked entities show layer names in legend
Given I open the Cases Malaria dashboard
When I hover over the map legend button
Then the legend title shows the tracked entity name

# TODO: flaky test
# @mutating
# Scenario: I change the height of the control bar
Expand Down
34 changes: 34 additions & 0 deletions cypress/integration/view/view_dashboard/te_map_legend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps'
import { dashboards } from '../../../assets/backends/sierraLeone_236'
import { getDashboardItem, mapSel } from '../../../elements/dashboardItem'
import {
dashboardTitleSel,
dashboardChipSel,
} from '../../../elements/viewDashboard'
import { EXTENDED_TIMEOUT } from '../../../support/utils'

const mapItemUid = dashboards['Cases Malaria'].items.map.itemUid

Given('I open the Cases Malaria dashboard', () => {
const title = 'Cases Malaria'
cy.get(dashboardChipSel, EXTENDED_TIMEOUT).contains(title).click()

cy.location().should(loc => {
expect(loc.hash).to.equal(dashboards[title].route)
})

cy.get(dashboardTitleSel).should('be.visible').and('contain', title)
cy.get(mapSel, EXTENDED_TIMEOUT).should('exist')
})

When('I hover over the map legend button', () => {
getDashboardItem(mapItemUid)
.find('.dhis2-map-legend-button', EXTENDED_TIMEOUT)
.trigger('mouseover')
})

Then('the legend title shows the tracked entity name', () => {
cy.get('.dhis2-map-legend-title')
.contains('Malaria case registration')
.should('be.visible')
})
19 changes: 13 additions & 6 deletions src/api/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,18 @@ export const getListItemFields = () => [
]

// Map
export const getMapFields = () => [
`${getIdNameFields({ rename: true }).join(',')}`,
'user,longitude,latitude,zoom,basemap',
`mapViews[${getFavoriteFields({
export const getMapFields = () => {
const favoriteFields = getFavoriteFields({
withDimensions: true,
withOptions: true,
})}]`,
]
})

const teFields =
'program[id,displayName~rename(name)],programStage[id,displayName~rename(name)],trackedEntityType[id,displayName~rename(name)]'

return [
`${getIdNameFields({ rename: true }).join(',')}`,
'user,longitude,latitude,zoom,basemap',
`mapViews[${favoriteFields.concat(teFields)}]`,
]
}

0 comments on commit 0d96c84

Please sign in to comment.