Skip to content

Commit

Permalink
test: add layout validation test for TE
Browse files Browse the repository at this point in the history
  • Loading branch information
martinkrulltott committed Dec 28, 2023
1 parent 8b5d058 commit 7bc3e33
Showing 1 changed file with 73 additions and 21 deletions.
94 changes: 73 additions & 21 deletions cypress/integration/layoutValidation.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,111 @@ import {
clickAddRemoveMainDimension,
clickAddRemoveProgramDimension,
openProgramDimensionsSidebar,
selectEnrollmentWithProgram,
selectEventWithProgram,
selectTrackedEntityWithType,
} from '../helpers/dimensions.js'
import { clickMenubarUpdateButton } from '../helpers/menubar.js'
import { goToStartPage } from '../helpers/startScreen.js'
import { expectTableToBeVisible } from '../helpers/table.js'

// TODO: refactor out sequential tests
// TODO: duplicate and adapt to TE
describe('layout validation', () => {
const types = ['event', 'enrollment']
types.forEach((type) => {
it(`validates that program, columns and org unit are required (${type})`, () => {
const trackerProgram = CHILD_PROGRAM

/* This files constains sequential tests, which means that some test steps
* depend on a previous step. With test isolation switched on (the default setting)
* each step (`it` block) will start off in a fresh window, and that breaks this kind
* of test. So `testIsolation` was set to false here. */
describe('layout validation', { testIsolation: false }, () => {
const trackerProgram = CHILD_PROGRAM
goToStartPage()

it('program is required', () => {
if (type === 'enrollemnt') {
cy.getBySel('input-enrollment').click()
}

clickMenubarUpdateButton()

cy.getBySel('error-container').contains('No program selected')

if (type === 'event') {
// select a program (without selecting stage, should auto-select)
selectEventWithProgram({
programName: trackerProgram.programName,
})
} else {
selectEnrollmentWithProgram({
programName: trackerProgram.programName,
})
}

openProgramDimensionsSidebar()

// remove org unit
clickAddRemoveProgramDimension('Organisation unit')

clickMenubarUpdateButton()

// columns is required
cy.getBySel('error-container').contains('Columns is empty')

// add something other than org unit to columns
clickAddRemoveMainDimension('Last updated by')

clickMenubarUpdateButton()

// org unit dimension is required
cy.getBySel('error-container').contains(
'No organisation unit selected'
)

// remove previously added dimension
clickAddRemoveMainDimension('Last updated by')

// add org unit to columns
clickAddRemoveProgramDimension('Organisation unit')

clickMenubarUpdateButton()

// validation succeeds when all above are provided
expectTableToBeVisible()
})
})
it('validates that type and org unit are required (TE)', () => {
goToStartPage()

cy.getBySel('input-tracked-entity').click()

clickMenubarUpdateButton()

cy.getBySel('error-container').contains('No program selected')
})
it('columns is required', () => {
// select a program (without selecting stage, should auto-select)
selectEventWithProgram({ programName: trackerProgram.programName })
cy.getBySel('error-container').contains(
'No tracked entity type selected'
)

openProgramDimensionsSidebar()
selectTrackedEntityWithType('Person')

// remove org unit
clickAddRemoveProgramDimension('Organisation unit')
clickAddRemoveMainDimension('Registration org. unit')

clickMenubarUpdateButton()

// columns is required
cy.getBySel('error-container').contains('Columns is empty')
})
it('org unit dimension is required', () => {

// add something other than org unit to columns
clickAddRemoveMainDimension('Last updated by')

clickMenubarUpdateButton()

// org unit dimension is required
cy.getBySel('error-container').contains('No organisation unit selected')
})
it('validation succeeds when all above are provided', () => {

// remove previously added dimension
clickAddRemoveMainDimension('Last updated by')

// add org unit to columns
clickAddRemoveProgramDimension('Organisation unit')
clickAddRemoveMainDimension('Registration org. unit')

clickMenubarUpdateButton()

// validation succeeds when all above are provided
expectTableToBeVisible()
})
})

0 comments on commit 7bc3e33

Please sign in to comment.