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

chore: useCachedQueryProvider to ensure required data is loaded for rendering #2940

Merged
merged 17 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 13 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
33 changes: 33 additions & 0 deletions cypress/elements/thematic_layer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { Layer } from './layer.js'

export class ThematicLayer extends Layer {
selectItemType(itemType) {
cy.getByDataTest('itemtypeselect').click()
cy.contains(itemType).click()

return this
}
selectIndicatorGroup(indicatorGroup) {
cy.get('[data-test="indicatorgroupselect"]').click()
cy.contains(indicatorGroup).click()
Expand All @@ -15,6 +21,33 @@ export class ThematicLayer extends Layer {
return this
}

selectDataElementGroup(dataElementGroup) {
cy.getByDataTest('dataelementgroupselect').click()
cy.getByDataTest('dhis2-uicore-singleselectoption')
.contains(dataElementGroup)
.click()

return this
}

selectDataElement(dataElement) {
cy.getByDataTest('dataelementselect').click()
cy.getByDataTest('dhis2-uicore-singleselectoption')
.contains(dataElement)
.click()

return this
}

selectDataElementOperand(dataElementOperand) {
cy.getByDataTest('dataelementoperandselect').click()
cy.getByDataTest('dhis2-uicore-singleselectoption')
.contains(dataElementOperand)
.click()

return this
}

selectPeriodType(periodType) {
cy.get('[data-test="periodtypeselect"]').click()
cy.contains(periodType).click()
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/basemaps.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('Basemap checks', () => {
checkBasemap.activeBasemap('OSM Light')
})

it.skip('open map with unknown basemap uses system default basemap (which is set to an external basemap)', () => {
it('open map with unknown basemap uses system default basemap (which is set to an external basemap)', () => {
cy.intercept(SYSTEM_SETTINGS_ENDPOINT, (req) => {
delete req.headers['if-none-match']
req.continue((res) => {
Expand Down
149 changes: 88 additions & 61 deletions cypress/integration/systemsettings.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { checkBasemap } from '../elements/basemap_card.js'
import { ThematicLayer } from '../elements/thematic_layer.js'
import { EXTENDED_TIMEOUT } from '../support/util.js'
import { EXTENDED_TIMEOUT, getApiBaseUrl } from '../support/util.js'

const SYSTEM_SETTINGS_ENDPOINT = { method: 'GET', url: 'systemSettings?*' }

Expand Down Expand Up @@ -89,69 +90,95 @@ describe('systemSettings', () => {
.should('be.visible')
})

it.skip('uses Last 6 months as default relative period', () => {
cy.intercept(SYSTEM_SETTINGS_ENDPOINT, (req) => {
delete req.headers['if-none-match']
req.continue((res) => {
res.body.keyAnalysisRelativePeriod = 'LAST_6_MONTHS'

res.send({
body: res.body,
})
})
}).as('getSystemSettings6months')

cy.visit('/', EXTENDED_TIMEOUT)
cy.get('canvas', EXTENDED_TIMEOUT).should('be.visible')
cy.wait('@getSystemSettings6months', EXTENDED_TIMEOUT)
.its('response.statusCode')
.should('eq', 200)

// Open/close file menu is a hack to trigger a ui change, ensuring that
// systemSettings has completed
cy.getByDataTest('file-menu-toggle').click()
cy.getByDataTest('file-menu-toggle-layer').click()

cy.wait(2000) // eslint-disable-line cypress/no-unnecessary-waiting

const Layer = new ThematicLayer()

Layer.openDialog('Thematic')
.selectIndicatorGroup('HIV')
.selectIndicator('VCCT post-test counselling rate')
.selectTab('Org Units')
.selectOu('Sierra Leone')
.addToMap()

Layer.validateCardPeriod('Last 6 months')
it('uses Last 6 months as default relative period', () => {
// set relative period to 6 months
cy.request({
method: 'POST',
url: `${getApiBaseUrl()}/api/systemSettings/keyAnalysisRelativePeriod`,
headers: {
'Content-Type': 'text/plain',
},
body: 'LAST_6_MONTHS',
}).then((response) => {
expect(response.status).to.eq(200)

cy.visit('/', EXTENDED_TIMEOUT)
cy.get('canvas', EXTENDED_TIMEOUT).should('be.visible')

const Layer = new ThematicLayer()

Layer.openDialog('Thematic')
.selectIndicatorGroup('HIV')
.selectIndicatorGroup('ANC')
.selectIndicator('ANC 1 Coverage')
.selectTab('Org Units')
.selectOu('Sierra Leone')
.addToMap()

Layer.validateCardPeriod('Last 6 months')
})
})

it.skip('uses Last 12 months as default relative period', () => {
cy.intercept(SYSTEM_SETTINGS_ENDPOINT, (req) => {
delete req.headers['if-none-match']
req.continue((res) => {
res.body.keyAnalysisRelativePeriod = 'LAST_12_MONTHS'
it('uses Last 12 months as default relative period', () => {
// set relative period to 12 months
cy.request({
method: 'POST',
url: `${getApiBaseUrl()}/api/systemSettings/keyAnalysisRelativePeriod`,
headers: {
'Content-Type': 'text/plain',
},
body: 'LAST_12_MONTHS',
}).then((response) => {
expect(response.status).to.eq(200)

cy.visit('/', EXTENDED_TIMEOUT)
cy.get('canvas', EXTENDED_TIMEOUT).should('be.visible')

const Layer = new ThematicLayer()

Layer.openDialog('Thematic')
.selectIndicatorGroup('HIV')
.selectIndicatorGroup('ANC')
.selectIndicator('ANC 1 Coverage')
.selectTab('Org Units')
.selectOu('Sierra Leone')
.addToMap()

Layer.validateCardPeriod('Last 12 months')
})
})

res.send({
body: res.body,
})
it('uses the correct default basemap', () => {
cy.request({
method: 'POST',
url: `${getApiBaseUrl()}/api/systemSettings/keyDefaultBaseMap`,
headers: {
'Content-Type': 'text/plain',
},
body: 'wNIQ8pNvSQd',
}).then((response) => {
expect(response.status).to.eq(200)

cy.visit('/', EXTENDED_TIMEOUT)
cy.get('canvas', EXTENDED_TIMEOUT).should('be.visible')

checkBasemap.activeBasemap('Terrain basemap')

cy.request({
method: 'POST',
url: `${getApiBaseUrl()}/api/systemSettings/keyDefaultBaseMap`,
headers: {
'Content-Type': 'text/plain',
},
body: 'osmLight',
}).then((response) => {
expect(response.status).to.eq(200)

cy.visit('/', EXTENDED_TIMEOUT)
cy.get('canvas', EXTENDED_TIMEOUT).should('be.visible')

checkBasemap.activeBasemap('OSM Light')
})
}).as('getSystemSettings12months')

cy.visit('/', EXTENDED_TIMEOUT)
cy.wait('@getSystemSettings12months')

cy.wait(2000) // eslint-disable-line cypress/no-unnecessary-waiting

const Layer = new ThematicLayer()

Layer.openDialog('Thematic')
.selectIndicatorGroup('HIV')
.selectIndicator('VCCT post-test counselling rate')
.selectTab('Org Units')
.selectOu('Sierra Leone')
.addToMap()

Layer.validateCardPeriod('Last 12 months')
})
})
})
Loading
Loading