Skip to content

Commit

Permalink
test: add tests for totals/cumulative with mixed valueTypes/totalAggr…
Browse files Browse the repository at this point in the history
…egationTypes
  • Loading branch information
edoardo committed Oct 18, 2024
1 parent 0607288 commit 09d9d43
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 1 deletion.
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
59 changes: 59 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 @@ -33,17 +36,20 @@ import {
} from '../../elements/optionsModal/index.js'
import {
colTotalsOptionEl,
rowTotalsOptionEl,

Check failure on line 39 in cypress/integration/options/cumulativeValues.cy.js

View workflow job for this annotation

GitHub Actions / lint

'rowTotalsOptionEl' is defined but never used
expectColumnsTotalsToBeChecked,
expectColumnsTotalsToBeDisabled,
expectColumnsSubTotalsToBeDisabled,
expectRowsTotalsToBeDisabled,
expectRowsSubTotalsToBeDisabled,
expectColumnsTotalsToBeEnabled,
expectColumnsSubTotalsToBeEnabled,
expectRowsTotalsToBeChecked,

Check failure on line 47 in cypress/integration/options/cumulativeValues.cy.js

View workflow job for this annotation

GitHub Actions / lint

'expectRowsTotalsToBeChecked' is defined but never used
expectRowsTotalsToBeEnabled,
expectRowsSubTotalsToBeEnabled,
} from '../../elements/optionsModal/totals.js'
import {
expectTableToBeVisible,
expectTableValueCellToContainValue,
clickTableHeaderCell,
} from '../../elements/pivotTable.js'
Expand Down Expand Up @@ -217,5 +223,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')
})
})
})
58 changes: 58 additions & 0 deletions cypress/integration/options/totals.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
clickDimensionModalUpdateButton,
expectDimensionModalToBeVisible,
inputSearchTerm,
clearSearchTerm,
selectAllItemsByButton,
selectDataElements,
selectDataItems,
Expand All @@ -31,7 +32,9 @@ import {
} from '../../elements/optionsModal/index.js'
import {
colTotalsOptionEl,
rowTotalsOptionEl,
expectColumnsTotalsToBeChecked,
expectRowsTotalsToBeChecked,
} from '../../elements/optionsModal/totals.js'
import {
expectTableToBeVisible,
Expand Down Expand Up @@ -113,3 +116,58 @@ describe('Options - Column totals', () => {
})
})
})

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')
})
})
})

0 comments on commit 09d9d43

Please sign in to comment.