Skip to content

Commit

Permalink
Merge branch 'dev' into feat/DHIS2-15657-analytics-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
janhenrikoverland authored Nov 2, 2023
2 parents 2d630d9 + cadf291 commit 983128c
Show file tree
Hide file tree
Showing 4 changed files with 229 additions and 232 deletions.
28 changes: 14 additions & 14 deletions cypress/integration/confirmLeave.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,34 @@ import {
import { TEST_AOS } from '../utils/data.js'
import { getRandomArrayItem } from '../utils/random.js'

describe('confirm leave modal', () => {
const TEST_AO = getRandomArrayItem(TEST_AOS)

it('navigates to the start page and loads a random saved AO', () => {
describe('Confirm leave modal', () => {
it('Confirm leave modal preserves AO changes when user cancels leave, and discards changes when user approves leave', () => {
const TEST_AO = getRandomArrayItem(TEST_AOS)
// navigates to the start page and loads a random saved AO
goToStartPage()
openAOByName(TEST_AO.name)
expectVisualizationToBeVisible(TEST_AO.type)
expectAOTitleToNotBeDirty()
})
it(`replaces the selected period`, () => {

// replaces the selected period
replacePeriodItems(TEST_AO.type)
expectVisualizationToBeVisible(TEST_AO.type)
expectAOTitleToBeDirty()
})
it('tries to open a new AO', () => {

// tries to open a new AO
createNewAO()
expectConfirmLeaveModalToBeVisible()
})
it('cancels leave', () => {

// cancels leave
confirmLeave(false)
expectVisualizationToBeVisible(TEST_AO.type)
expectAOTitleToBeDirty()
})
it('tries to open a new AO', () => {

// tries to open a new AO
createNewAO()
expectConfirmLeaveModalToBeVisible()
})
it('confirms leave', () => {

// confirms leave
confirmLeave(true)
expectStartScreenToBeVisible()
expectVisualizationToNotBeVisible()
Expand Down
85 changes: 42 additions & 43 deletions cypress/integration/new.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,62 +41,61 @@ const TEST_INDICATOR_NAMES = TEST_INDICATORS.slice(1, 3).map(
)

describe('creating a new AO', () => {
it('navigates to the start page', () => {
goToStartPage()
})
visTypes.forEach((visType) => {
const visTypeName = visTypeDisplayNames[visType]
describe(visTypeName, () => {
it('creates a new AO', () => {
createNewAO()
expectStoreCurrentToBeEmpty()
expectVisualizationToNotBeVisible()
expectVisTypeToBeDefault()
})
it('changes vis type', () => {
changeVisType(visTypeName)
expectVisTypeToBeValue(visTypeName)
})
it('adds dimensions', () => {
openDimension(DIMENSION_ID_DATA)

if (visType === VIS_TYPE_SCATTER) {
selectIndicators(TEST_INDICATOR_NAMES.slice(0, 1))
switchDataTab('Horizontal')
selectDataElements(TEST_DATA_ELEMENT_NAMES.slice(0, 1))
} else {
if (getAxisMaxNumberOfItems(visType, TEST_AXIS_ID) === 1) {
// Gauge and SV can only have 1 data item
TEST_DATA_ELEMENT_NAMES.splice(1)
}
it(`create AO of type ${visTypeName}`, () => {
// navigates to start page
goToStartPage()

// creates a new AO
createNewAO()
expectStoreCurrentToBeEmpty()
expectVisualizationToNotBeVisible()
expectVisTypeToBeDefault()

// changes vis type
changeVisType(visTypeName)
expectVisTypeToBeValue(visTypeName)

selectDataElements(TEST_DATA_ELEMENT_NAMES)
// adds dimensions
openDimension(DIMENSION_ID_DATA)

if (visType === VIS_TYPE_SCATTER) {
selectIndicators(TEST_INDICATOR_NAMES.slice(0, 1))
switchDataTab('Horizontal')
selectDataElements(TEST_DATA_ELEMENT_NAMES.slice(0, 1))
} else {
if (getAxisMaxNumberOfItems(visType, TEST_AXIS_ID) === 1) {
// Gauge and SV can only have 1 data item
TEST_DATA_ELEMENT_NAMES.splice(1)
}

clickDimensionModalUpdateButton()
selectDataElements(TEST_DATA_ELEMENT_NAMES)
}

expectVisualizationToBeVisible(visType)
clickDimensionModalUpdateButton()

isYearOverYear(visType) && expectAOTitleToBeUnsaved()
expectVisualizationToBeVisible(visType)

// FIXME: Store is always in default state
/* !isYearOverYear(visType)
isYearOverYear(visType) && expectAOTitleToBeUnsaved()

// FIXME: Store is always in default state
/* !isYearOverYear(visType)
? expectStoreCurrentColumnsToHaveLength(1)
: expectAOTitleToBeUnsaved() */

if (visType !== VIS_TYPE_SCATTER) {
TEST_DATA_ELEMENT_NAMES.forEach((item) =>
expectChartToContainDimensionItem(visType, item)
)
}
})
if (visType !== VIS_TYPE_SCATTER) {
TEST_DATA_ELEMENT_NAMES.forEach((item) =>
expectChartToContainDimensionItem(visType, item)
)
}

if ([VIS_TYPE_SINGLE_VALUE, VIS_TYPE_GAUGE].includes(visType)) {
it('Data is locked to Series', () => {
expectDimensionOnAxisToHaveLockIcon(
DIMENSION_ID_DATA,
AXIS_ID_COLUMNS
)
})
expectDimensionOnAxisToHaveLockIcon(
DIMENSION_ID_DATA,
AXIS_ID_COLUMNS
)
}
})
})
Expand Down
Loading

0 comments on commit 983128c

Please sign in to comment.