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

test: add cypress tests for Outlier table DHIS2-17162 #3008

Merged
merged 8 commits into from
Apr 11, 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
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In which case is this needed to have?
!$typesSelect.text().includes(dataType) looks over-engineered to me 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment, perhaps is not very clear 😅
Basically, when you have only 1 type enabled, the whole select gets disabled with the preselected type, then the actions for selecting the type don't work.
So, the reasoning is, if the type you want is already selected, don't try to select it again, this accounts also for the case of only 1 type available described above.

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
Loading