Skip to content

Commit

Permalink
test: program status updates + adapt chip to new DOM structure
Browse files Browse the repository at this point in the history
  • Loading branch information
martinkrulltott committed Jan 24, 2024
1 parent a1b4e91 commit 6781115
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
20 changes: 14 additions & 6 deletions cypress/helpers/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,29 @@ export const expectAxisToNotHaveDimension = (axisId, dimensionId) => {
export const assertTooltipContainsEntries = (entries) =>
entries.forEach((entry) => cy.getBySel('tooltip-content').contains(entry))

export const assertChipContainsText = (dimensionName, suffix) => {
if (suffix) {
export const assertChipContainsText = (primary, items, secondary) => {
if (items) {
cy.getBySelLike('layout-chip')
.containsExact(dimensionName, EXTENDED_TIMEOUT)
.containsExact(primary, EXTENDED_TIMEOUT)
.parent()
.parent()
.findBySelLike('chip-items')
.contains(suffix, EXTENDED_TIMEOUT)
.contains(items, EXTENDED_TIMEOUT)
} else {
cy.getBySelLike('layout-chip')
.containsExact(dimensionName, EXTENDED_TIMEOUT)
.containsExact(primary, EXTENDED_TIMEOUT)
.parent()
.parent()
.findBySelLike('chip-items')
.should('not.exist')
}
if (secondary) {
cy.getBySelLike('layout-chip').containsExact(
secondary,
EXTENDED_TIMEOUT
)
}
cy.getBySelLike('layout-chip')
.containsExact(dimensionName, EXTENDED_TIMEOUT)
.containsExact(primary, EXTENDED_TIMEOUT)
.trigger('mouseover')
}
27 changes: 13 additions & 14 deletions cypress/integration/programStatus.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,16 @@ import {
} from '../helpers/table.js'

describe(['>=41'], 'program status (TE)', () => {
const dimensionName = 'Program status'

const setUpTable = () => {
goToStartPage()

selectTrackedEntityWithType('Malaria Entity')
selectTrackedEntityWithType('Person')

openProgramDimensionsSidebar()

selectProgramForTE(
'Malaria case diagnosis, treatment and investigation'
)
selectProgramForTE('Child Programme')

clickAddRemoveProgramDimension(dimensionName)
clickAddRemoveProgramDimension('Program status')

clickMenubarUpdateButton()

Expand All @@ -47,17 +43,15 @@ describe(['>=41'], 'program status (TE)', () => {

getTableRows().its('length').should('be.gte', 10)

// getTableHeaderCells().contains(dimensionName).should('be.visible')
// Backend issue, once resolved change back to the line above
getTableHeaderCells()
.contains('Enrollment PROGRAM_STATUS')
.contains('Program status, Child Programme')
.should('be.visible')

assertChipContainsText(dimensionName, 'all')
assertChipContainsText('Program status', 'all', 'Child Programme')

// Add filter 'Completed'

cy.getBySel('columns-axis').contains(dimensionName).click()
cy.getBySel('columns-axis').contains('Program status').click()

cy.getBySel('program-status-checkbox')
.contains('Completed')
Expand All @@ -71,9 +65,14 @@ describe(['>=41'], 'program status (TE)', () => {

expectTableToBeVisible()

expectTableToMatchRows(['Completed'])
expectTableToMatchRows([
'Completed',
'Completed',
'Completed',
'Completed',
])

assertChipContainsText(dimensionName, 1)
assertChipContainsText('Program status', 1, 'Child Programme')

assertTooltipContainsEntries(['Completed'])
})
Expand Down

0 comments on commit 6781115

Please sign in to comment.