Skip to content

Commit

Permalink
test: add cypress tests for Outlier table DHIS2-17162 (#3008)
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardo authored Apr 11, 2024
1 parent 01f8f3c commit db0c6da
Show file tree
Hide file tree
Showing 11 changed files with 378 additions and 180 deletions.
7 changes: 6 additions & 1 deletion cypress/elements/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
VIS_TYPE_COLUMN,
VIS_TYPE_GAUGE,
VIS_TYPE_PIE,
VIS_TYPE_OUTLIER_TABLE,
VIS_TYPE_PIVOT_TABLE,
VIS_TYPE_SINGLE_VALUE,
VIS_TYPE_YEAR_OVER_YEAR_COLUMN,
Expand All @@ -23,7 +24,11 @@ const AOTitleDirtyEl = 'titlebar-dirty'
const timeout = {
timeout: 40000,
}
const nonHighchartsTypes = [VIS_TYPE_PIVOT_TABLE, VIS_TYPE_SINGLE_VALUE]
const nonHighchartsTypes = [
VIS_TYPE_OUTLIER_TABLE,
VIS_TYPE_PIVOT_TABLE,
VIS_TYPE_SINGLE_VALUE,
]

export const expectVisualizationToBeVisible = (visType = VIS_TYPE_COLUMN) =>
nonHighchartsTypes.includes(visType)
Expand Down
14 changes: 12 additions & 2 deletions cypress/elements/dimensionModal/dataDimension.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const selectableItemsEl = 'data-dimension-transfer-sourceoptions'
const selectedItemsEl = 'data-dimension-transfer-pickedoptions'
const dataTypesSelectButtonEl =
'data-dimension-left-header-data-types-select-field-content'
const dataTypesSelectHelpEl =
'data-dimension-left-header-data-types-select-field-help'
const dataTypeSelectOptionEl =
'data-dimension-left-header-data-types-select-field-option'
const groupSelectButtonEl =
Expand Down Expand Up @@ -78,6 +80,9 @@ export const switchDataTab = (tabName) => {
export const expectDataTypeToBe = (type) =>
cy.getBySel(dataTypesSelectButtonEl).should('contain', type)

export const expectDataTypeSelectHelpToContain = (text) =>
cy.getBySel(dataTypesSelectHelpEl).should('have.text', text)

export const expectGroupSelectToNotBeVisible = () =>
cy.getBySel(groupSelectButtonEl).should('not.exist')

Expand Down Expand Up @@ -111,8 +116,13 @@ export const switchSubGroupTo = (group) => {
}

export const switchDataTypeTo = (dataType) => {
cy.getBySel(dataTypesSelectButtonEl).click()
cy.getBySelLike(dataTypeSelectOptionEl).contains(dataType).click()
cy.getBySel(dataTypesSelectButtonEl).then(($typesSelect) => {
// account for disabled type selector with preselected item
if (!$typesSelect.text().includes(dataType)) {
cy.getBySel(dataTypesSelectButtonEl).click()
cy.getBySelLike(dataTypeSelectOptionEl).contains(dataType).click()
}
})
}

export const switchDataTypeToAll = () => {
Expand Down
3 changes: 3 additions & 0 deletions cypress/elements/dimensionModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export {
expectDataItemToBeInactive,
expectDataDimensionModalToBeVisible,
expectDataTypeToBe,
expectDataTypeSelectHelpToContain,
expectGroupSelectToNotBeVisible,
expectNoDataItemsToBeSelected,
inputSearchTerm,
Expand Down Expand Up @@ -153,6 +154,8 @@ export {
expectFixedPeriodTypeToBe,
expectSelectablePeriodItemsAmountToBeLeast,
expectSelectablePeriodItemsAmountToBe,
expectPeriodItemToBeInactive,
expectPeriodDimensionModalWarningToContain,
} from './periodDimension.js'

export {
Expand Down
12 changes: 11 additions & 1 deletion cypress/elements/dimensionModal/periodDimension.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ const fixedPeriodsPeriodTypeButtonEl =
'period-dimension-fixed-period-filter-period-type-content'
const periodTypeMenuEl = 'dhis2-uicore-select-menu-menuwrapper'
//const fixedPeriodsYearEl = 'period-dimension-fixed-period-filter-year-content'
const optionContentEl = 'period-dimension-transfer-option-content'
const selectableItemsEl = 'period-dimension-transfer-sourceoptions'
const selectedItemsEl = 'period-dimension-transfer-pickedoptions'
const relativePeriodTypeSelectOptionEl =
'period-dimension-relative-period-filter-option'

const fixedPeriodTypeSelectOptionEl =
'period-dimension-fixed-period-filter-period-type-option'
const rightHeaderEl = 'period-dimension-transfer-rightheader'

export const expectPeriodDimensionModalToBeVisible = () =>
expectDimensionModalToBeVisible(DIMENSION_ID_PERIOD)
Expand Down Expand Up @@ -96,6 +97,12 @@ export const expectFixedPeriodTypeSelectToNotContain = (periodType) => {
)
}

export const expectPeriodItemToBeInactive = (id) =>
cy
.get(`[data-value="${id}"]`)
.findBySel(optionContentEl)
.should('have.class', 'inactive')

export const openRelativePeriodsTypeSelect = () =>
cy.getBySel(relativePeriodsPeriodTypeButtonEl).click()

Expand All @@ -117,3 +124,6 @@ export const expectSelectablePeriodItemsAmountToBeLeast = (amount) =>
$container.find('[data-test="period-dimension-transfer-option"]')
).to.have.length.of.at.least(amount)
})

export const expectPeriodDimensionModalWarningToContain = (text) =>
cy.getBySel(rightHeaderEl).should('contain', text)
Loading

0 comments on commit db0c6da

Please sign in to comment.