Skip to content

Commit

Permalink
chore: add time dimension check to cypress test
Browse files Browse the repository at this point in the history
  • Loading branch information
jenniferarnesen committed Feb 1, 2024
1 parent b050b69 commit ab52888
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 13 deletions.
42 changes: 40 additions & 2 deletions cypress/helpers/period.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,49 @@ const openPeriod = (label) => {
}
}

const selectFixedPeriod = ({ label, period }) => {
const selectFixedPeriod = ({ label, period, selected }) => {
openPeriod(label)
cy.contains('Choose from presets').click()
cy.contains('Fixed periods').click()
if (period.type) {

if (selected) {
// confirm that selected item is in the correct list in the transfer
if (
period.type &&
!cy
.getBySel(
'period-dimension-fixed-period-filter-period-type-content'
)
.contains(period.type)
) {
cy.getBySel(
'period-dimension-fixed-period-filter-period-type-content'
).click()
cy.getBySelLike(
'period-dimension-fixed-period-filter-period-type-option'
)
.contains(period.type)
.click()
}

cy.getBySel('period-dimension-transfer-sourceoptions')
.contains(selected.name)
.should('not.exist')

cy.getBySel('period-dimension-transfer-pickedoptions').containsExact(
selected.name
)
}

// only select period type if it's not the current value because otherwise the dropdown doesn't close
if (
period.type &&
!cy
.getBySel(
'period-dimension-fixed-period-filter-period-type-content'
)
.contains(period.type)
) {
cy.getBySel(
'period-dimension-fixed-period-filter-period-type-content'
).click()
Expand Down
68 changes: 57 additions & 11 deletions cypress/integration/createTrackedEntity.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from '../helpers/dimensions.js'
import { assertChipContainsText } from '../helpers/layout.js'

Check failure on line 13 in cypress/integration/createTrackedEntity.cy.js

View workflow job for this annotation

GitHub Actions / lint

'assertChipContainsText' is defined but never used
import { clickMenubarUpdateButton } from '../helpers/menubar.js'
import { selectFixedPeriod, getCurrentYearStr } from '../helpers/period.js'
import { goToStartPage } from '../helpers/startScreen.js'
import { expectTableToBeVisible } from '../helpers/table.js'

Expand All @@ -24,7 +25,7 @@ const program = {
}
const entityDimensionName = 'City'
const programDataDimensionName = 'MCH Infant Weight (g)'
// const periodLabel = program[DIMENSION_ID_ENROLLMENT_DATE]
const periodLabel = program[DIMENSION_ID_ENROLLMENT_DATE]

describe(['>=41'], 'tracked entity', () => {
beforeEach(() => {
Expand Down Expand Up @@ -75,37 +76,82 @@ const setUpTable = () => {

selectProgramForTE(program.programName)

cy.getBySel('dimension-item-eventDate').should('not.exist')

// Check the correct time dimensions are displayed, and with program/stage specific name
cy.getBySel(`dimension-item-${program.id}.enrollmentDate`).contains(
program[DIMENSION_ID_ENROLLMENT_DATE]
)

cy.getBySel('dimension-item-scheduledDate').should('not.exist')

cy.getBySel(`dimension-item-${program.id}.incidentDate`).contains(
program[DIMENSION_ID_INCIDENT_DATE]
)

cy.getBySel('dimension-item-lastUpdated').contains(
program[DIMENSION_ID_LAST_UPDATED]
)
cy.getBySel('dimension-item-eventDate').should('not.exist')
cy.getBySel('dimension-item-scheduledDate').should('not.exist')

// Add a program data dimension
clickAddRemoveProgramDataDimension(programDataDimensionName)

// selectFixedPeriod({ label: periodLabel, period: TEST_FIX_PE_DEC_LAST_YEAR }) // FIXME: Time dimensions aren't implemented yet
const januaryThisYear = {
type: 'Monthly',
year: `${getCurrentYearStr()}`,
name: `January ${getCurrentYearStr()}`,
}

// Add a time dimension
selectFixedPeriod({
label: periodLabel,
period: januaryThisYear,
})

// Check the chip and tooltip content
cy.getBySelLike('layout-chip').contains(periodLabel).trigger('mouseover')
cy.getBySel('layout-chip-tooltip-content').contains(
`January ${getCurrentYearStr()}`
)
cy.getBySelLike('layout-chip').contains(periodLabel).trigger('mouseout')
cy.getBySel('layout-chip-tooltip-content').should('not.exist')

// Add another time dimension
// Check that the already selected period is not available to select

selectFixedPeriod({
label: periodLabel,
period: {
type: 'Monthly',
year: `${getCurrentYearStr()}`,
name: `February ${getCurrentYearStr()}`,
},
selected: januaryThisYear,
})

// Check the chip and tooltip content
cy.getBySelLike('layout-chip').contains(periodLabel).trigger('mouseover')

cy.getBySel('layout-chip-tooltip-content').contains(
`Program: ${program.programName}`
)
cy.getBySel('layout-chip-tooltip-content').contains(
`January ${getCurrentYearStr()}`
)
cy.getBySel('layout-chip-tooltip-content').contains(
`February ${getCurrentYearStr()}`
)

cy.getBySelLike('layout-chip').contains(periodLabel).trigger('mouseout')
cy.getBySel('layout-chip-tooltip-content').should('not.exist')

// Go back to person dimensions to verify that they're still listed properly
cy.getBySel('main-sidebar').contains('Person dimensions').click()
cy.getBySel('tracked-entity-dimensions-list')
.children()
.should('have.length', 33)

clickMenubarUpdateButton()
// clickMenubarUpdateButton()

expectTableToBeVisible()
// expectTableToBeVisible()

assertChipContainsText(entityDimensionName, 'all')
// assertChipContainsText(entityDimensionName, 'all')
}

// const runTests = () => {
Expand Down

0 comments on commit ab52888

Please sign in to comment.