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: compute subtotals/totals for boolean types (DHIS2-9155) #3194

Merged
merged 17 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions cypress/elements/dimensionModal/dataDimension.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ export const selectDataElements = (dataElements) => {
dataElements.forEach((item) => selectItemByDoubleClick(item))
}

export const selectDataItems = (dataItems) => {
expectSourceToNotBeLoading()
expectDataItemsToBeInSource(dataItems)
dataItems.forEach((item) => selectItemByDoubleClick(item))
}

export const selectFirstDataItem = () =>
cy.getBySel(selectableItemsEl).findBySel(optionContentEl).eq(0).dblclick()

Expand Down
1 change: 1 addition & 0 deletions cypress/elements/dimensionModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export const expectSelectedItemsAmountToBe = (amount) =>

export {
selectDataElements,
selectDataItems,
selectIndicators,
switchDataTab,
expectDataDimensionModalWarningToContain,
Expand Down
2 changes: 1 addition & 1 deletion cypress/elements/optionsModal/totals.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const colTotalsOptionEl = 'option-col-totals'
const colSubTotalsOptionEl = 'option-col-subtotals'
const rowTotalsOptionEl = 'option-row-totals'
export const rowTotalsOptionEl = 'option-row-totals'
const rowSubTotalsOptionEl = 'option-row-subtotals'

export const expectColumnsTotalsToBeDisabled = () =>
Expand Down
57 changes: 57 additions & 0 deletions cypress/integration/options/cumulativeValues.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import { checkCheckbox, uncheckCheckbox } from '../../elements/common.js'
import {
clickDimensionModalHideButton,
clickDimensionModalUpdateButton,
clearSearchTerm,
inputSearchTerm,
selectDataElements,
selectDataItems,
selectFixedPeriods,
unselectAllItemsByButton,
} from '../../elements/dimensionModal/index.js'
Expand All @@ -44,6 +47,7 @@ import {
expectRowsSubTotalsToBeEnabled,
} from '../../elements/optionsModal/totals.js'
import {
expectTableToBeVisible,
expectTableValueCellToContainValue,
clickTableHeaderCell,
} from '../../elements/pivotTable.js'
Expand Down Expand Up @@ -217,5 +221,58 @@ describe('Options - Cumulative values', () => {
expectTableValueCellToContainValue(2, '18 000')
expectTableValueCellToContainValue(5, '18 488')
})

it('accumulates for numeric/boolean value types with totalAggregationType SUM skipping other values', () => {
openDimension(DIMENSION_ID_DATA)

inputSearchTerm('ANC')
selectDataItems(['ANC 1st visit', 'ANC 2nd visit'])
clearSearchTerm()
inputSearchTerm('Coverage')
selectDataItems(['ANC 1 Coverage'])
clearSearchTerm()
inputSearchTerm('Cholera')
selectDataItems(['Cholera (Deaths < 5 yrs) Narrative'])
clearSearchTerm()
inputSearchTerm('ANC')
selectDataItems([
'ANC 3rd visit',
'ANC 2 Coverage',
'ANC 4th or more visits',
])
clearSearchTerm()
inputSearchTerm('Child')
selectDataItems([
'Child Health - Reporting rate',
'Child Programme MCH Apgar Score',
])
clearSearchTerm()
inputSearchTerm('BCG')
selectDataItems(['BCG doses'])
clickDimensionModalHideButton()

const year = new Date().getFullYear().toString()
openDimension(DIMENSION_ID_PERIOD)
unselectAllItemsByButton()
selectFixedPeriods([`October ${year}`], 'Monthly')

clickDimensionModalHideButton()

openOptionsModal(OPTIONS_TAB_DATA)
checkCheckbox(cumulativeValuesOptionEl)

clickOptionsModalUpdateButton()

expectTableToBeVisible()

expectTableValueCellToContainValue(1, '37 765')
expectTableValueCellToContainValue(2, '89.75')
expectTableValueCellToContainValue(4, '52 407')
expectTableValueCellToContainValue(5, '88.93')
expectTableValueCellToContainValue(6, '61 333')
expectTableValueCellToContainValue(7, '71.54')
expectTableValueCellToContainValue(8, '61 333.98')
expectTableValueCellToContainValue(9, '61 664.98')
})
})
})
93 changes: 92 additions & 1 deletion cypress/integration/options/totals.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ import {
clickDimensionModalHideButton,
clickDimensionModalUpdateButton,
expectDimensionModalToBeVisible,
inputSearchTerm,
clearSearchTerm,
selectAllItemsByButton,
selectDataElements,
selectDataItems,
selectFixedPeriods,
unselectAllItemsByButton,
} from '../../elements/dimensionModal/index.js'
Expand All @@ -29,9 +32,14 @@ import {
} from '../../elements/optionsModal/index.js'
import {
colTotalsOptionEl,
rowTotalsOptionEl,
expectColumnsTotalsToBeChecked,
expectRowsTotalsToBeChecked,
} from '../../elements/optionsModal/totals.js'
import { expectTableToBeVisible } from '../../elements/pivotTable.js'
import {
expectTableToBeVisible,
expectTableValueCellToContainValue,
} from '../../elements/pivotTable.js'
import { goToStartPage } from '../../elements/startScreen.js'
import { changeVisType } from '../../elements/visualizationTypeSelector.js'
import { TEST_CUSTOM_DIMENSIONS } from '../../utils/data.js'
Expand Down Expand Up @@ -79,4 +87,87 @@ describe('Options - Column totals', () => {
expectTableToBeVisible()
})
})

describe('Regression test for DHIS2-9155', () => {
it('computes totals for boolean value types', () => {
goToStartPage()
changeVisType(visTypeDisplayNames[VIS_TYPE_PIVOT_TABLE])

openOptionsModal(OPTIONS_TAB_DATA)
checkCheckbox(colTotalsOptionEl)

expectColumnsTotalsToBeChecked()

clickOptionsModalHideButton()

openDimension(DIMENSION_ID_DATA)
inputSearchTerm('yes')
selectDataItems([
'E2E program E2E - Yes only',
'E2E program E2E - Yes/no',
])
clickDimensionModalUpdateButton()

expectTableToBeVisible()

// XXX is there a better way to address the total value cells?
expectTableValueCellToContainValue(12, 4)
expectTableValueCellToContainValue(13, 4)
})
})
})

describe('Options - Row totals', () => {
describe('Totals with mixed valueType/totalAggregationType', () => {
it('shows N/A when values along the row cannot be summed', () => {
goToStartPage()
changeVisType(visTypeDisplayNames[VIS_TYPE_PIVOT_TABLE])

openOptionsModal(OPTIONS_TAB_DATA)
checkCheckbox(rowTotalsOptionEl)

expectRowsTotalsToBeChecked()

clickOptionsModalHideButton()

openDimension(DIMENSION_ID_DATA)

inputSearchTerm('ANC')
selectDataItems(['ANC 1st visit', 'ANC 2nd visit'])
clearSearchTerm()
inputSearchTerm('Coverage')
selectDataItems(['ANC 1 Coverage'])
clearSearchTerm()
inputSearchTerm('Cholera')
selectDataItems(['Cholera (Deaths < 5 yrs) Narrative'])
clearSearchTerm()
inputSearchTerm('ANC')
selectDataItems([
'ANC 3rd visit',
'ANC 2 Coverage',
'ANC 4th or more visits',
])
clearSearchTerm()
inputSearchTerm('Child')
selectDataItems([
'Child Health - Reporting rate',
'Child Programme MCH Apgar Score',
])
clearSearchTerm()
inputSearchTerm('BCG')
selectDataItems(['BCG doses'])
clickDimensionModalHideButton()

const year = new Date().getFullYear().toString()
openDimension(DIMENSION_ID_PERIOD)
unselectAllItemsByButton()
selectFixedPeriods([`October ${year}`], 'Monthly')

clickDimensionModalUpdateButton()

expectTableToBeVisible()

expectTableValueCellToContainValue(10, 'N/A')
})
})
})
2 changes: 2 additions & 0 deletions d2.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const config = {
app: './src/AppWrapper.js',
plugin: './src/PluginWrapper.js',
},

skipPluginLogic: true,
}

module.exports = config
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"typescript": "^4.8.4"
},
"dependencies": {
"@dhis2/analytics": "^26.8.1",
"@dhis2/analytics": "^26.8.7",
"@dhis2/app-runtime": "^3.10.4",
"@dhis2/app-runtime-adapter-d2": "^1.1.0",
"@dhis2/app-service-datastore": "^1.0.0-beta.3",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2050,10 +2050,10 @@
classnames "^2.3.1"
prop-types "^15.7.2"

"@dhis2/analytics@^26.8.1":
version "26.8.1"
resolved "https://registry.yarnpkg.com/@dhis2/analytics/-/analytics-26.8.1.tgz#ad72b326e92f0440a0280fc223ff0b85483eac5f"
integrity sha512-0y2RMlP1VucSaKCSGIsY4EwYmg6dg3ig765j7StOhbgT6wbRnE32VrQibG/sElGN3jwGf58frIGntEXdqGbjuw==
"@dhis2/analytics@^26.8.7":
version "26.8.7"
resolved "https://registry.yarnpkg.com/@dhis2/analytics/-/analytics-26.8.7.tgz#46838366066ddd1f92ab7b5bc78f1d87b4f56b75"
integrity sha512-zPdxVDL8IhCwZF2zDEj+2TPG1kS4MTJUgM2xGjSHnBFfrsn/ddN8D8x2tu+V4hh5F+xYggSkMNeGi2hwLsml+A==
dependencies:
"@dhis2/multi-calendar-dates" "^1.2.2"
"@dnd-kit/core" "^6.0.7"
Expand Down
Loading