Skip to content

Commit

Permalink
test: adapt tests to new database
Browse files Browse the repository at this point in the history
(cherry picked from commit 1156a51)
  • Loading branch information
martinkrulltott authored and edoardo committed Feb 28, 2024
1 parent 73c705c commit 9e35dd6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
1 change: 1 addition & 0 deletions cypress/elements/dimensionsPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const expectDimensionToNotHaveSelectedStyle = (dimensionId) =>
export const expectRecommendedIconToBeVisible = (dimensionId) =>
cy
.getBySel(getDimensionButtonById(dimensionId))
.scrollIntoView()
.findBySel(recommendedIconEl)
.should('have.length', 1)
.and('be.visible')
2 changes: 1 addition & 1 deletion cypress/integration/dimensions/data.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ describe('Data dimension', () => {
{
name: 'Event data items',
testGroup: { name: 'Information Campaign', itemAmount: 6 },
testItem: { name: 'Diagnosis (ICD-10)' },
testItem: { name: 'E2E TE program 1 First name' },
defaultGroup: { name: 'All programs' },
endpoint: {
hasMultiplePages: true,
Expand Down
26 changes: 12 additions & 14 deletions cypress/integration/dimensions/dynamic.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,25 @@ import {
expectDimensionToHaveItemAmount,
} from '../../elements/layout.js'
import { goToStartPage } from '../../elements/startScreen.js'
import { TEST_DATA_ELEMENTS } from '../../utils/data.js'
import { getRandomArrayItem } from '../../utils/random.js'
import { expectWindowConfigSeriesToHaveLength } from '../../utils/window.js'

const TEST_DATA_ELEMENT_NAME = getRandomArrayItem(TEST_DATA_ELEMENTS).name
const TEST_DYNAMIC_DIMENSION = {
id: 'J5jldMd8OHv',
name: 'Facility type',
itemAmount: 5,
}

describe(`Dynamic dimension - ${TEST_DYNAMIC_DIMENSION.name}`, () => {
it('navigates to the start page and adds a data item', () => {
it('can add and remove items, which persist after saving', () => {
cy.log('navigates to the start page and adds a data item')
goToStartPage()
openDimension(DIMENSION_ID_DATA)
selectDataElements([TEST_DATA_ELEMENT_NAME])
selectDataElements(['ANC 2nd visit'])
clickDimensionModalUpdateButton()
expectVisualizationToBeVisible(VIS_TYPE_COLUMN)
})
const TEST_ITEM = 'Hospital'
it('adds an item manually', () => {

const TEST_ITEM = 'Hospital'
cy.log('adds an item manually')
openDimension(TEST_DYNAMIC_DIMENSION.id)
expectDimensionModalToBeVisible(TEST_DYNAMIC_DIMENSION.id)
expectManualSelectionToBeChecked()
Expand All @@ -49,8 +47,8 @@ describe(`Dynamic dimension - ${TEST_DYNAMIC_DIMENSION.name}`, () => {
expectVisualizationToBeVisible(VIS_TYPE_COLUMN)
expectWindowConfigSeriesToHaveLength(1)
expectDimensionToHaveItemAmount(TEST_DYNAMIC_DIMENSION.id, 1)
})
it('adds all items automatically', () => {

cy.log('adds all items automatically')
openDimension(TEST_DYNAMIC_DIMENSION.id)
expectDimensionModalToBeVisible(TEST_DYNAMIC_DIMENSION.id)
expectManualSelectionToBeChecked()
Expand All @@ -60,8 +58,8 @@ describe(`Dynamic dimension - ${TEST_DYNAMIC_DIMENSION.name}`, () => {
expectVisualizationToBeVisible(VIS_TYPE_COLUMN)
expectWindowConfigSeriesToHaveLength(TEST_DYNAMIC_DIMENSION.itemAmount)
expectDimensionToHaveAllItemsSelected(TEST_DYNAMIC_DIMENSION.id)
})
it('switches back to manual and previous item is presisted', () => {

cy.log('switches back to manual and previous item is persisted')
openDimension(TEST_DYNAMIC_DIMENSION.id)
expectDimensionModalToBeVisible(TEST_DYNAMIC_DIMENSION.id)
expectAutomaticSelectionToBeChecked()
Expand All @@ -72,8 +70,8 @@ describe(`Dynamic dimension - ${TEST_DYNAMIC_DIMENSION.name}`, () => {
expectVisualizationToBeVisible(VIS_TYPE_COLUMN)
expectWindowConfigSeriesToHaveLength(1)
expectDimensionToHaveItemAmount(TEST_DYNAMIC_DIMENSION.id, 1)
})
it('switches back to automatic, saving, the selection is presisted', () => {

cy.log('switches back to automatic, saving, the selection is persisted')
openDimension(TEST_DYNAMIC_DIMENSION.id)
expectDimensionModalToBeVisible(TEST_DYNAMIC_DIMENSION.id)
expectManualSelectionToBeChecked()
Expand Down

0 comments on commit 9e35dd6

Please sign in to comment.