Skip to content

Commit

Permalink
test: refactor scatter to a single test case + wait for loading
Browse files Browse the repository at this point in the history
  • Loading branch information
martinkrulltott committed Dec 15, 2023
1 parent 0c487e8 commit ddfae31
Showing 1 changed file with 42 additions and 34 deletions.
76 changes: 42 additions & 34 deletions cypress/integration/visTypes/scatter.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,26 @@ const TEST_INDICATOR_NAMES = TEST_INDICATORS.slice(1, 4).map(
)
const TEST_VIS_NAME = `TEST SCATTER ${new Date().toLocaleString()}`

describe('using a Scatter chart', () => {
it('navigates to a new Scatter chart', () => {
describe('Scatter chart', () => {
it('works correctly (create, save, load, swap etc)', () => {
cy.log('navigates to a new Scatter chart')
goToStartPage()
changeVisType(visTypeDisplayNames[VIS_TYPE_SCATTER])
})
it("shows an error message when vertical and horizontal isn't selected", () => {

cy.log(
"shows an error message when vertical and horizontal isn't selected"
)
clickMenuBarUpdateButton()
expectErrorToContainTitle('Vertical is empty')
})
it('adds a vertical item and shows an error message', () => {

cy.log('adds a vertical item and shows an error message')
openDimension(DIMENSION_ID_DATA)
selectIndicators([TEST_INDICATOR_NAMES[0]])
clickDimensionModalUpdateButton()
expectErrorToContainTitle('Horizontal is empty')
expectVerticalToContainDimensionLabel(TEST_INDICATOR_NAMES[0])
})
it('adds a horizontal item and displays a chart', () => {

cy.log('adds a horizontal item and displays a chart')
openDimension(DIMENSION_ID_DATA)
switchDataTab('Horizontal')
selectIndicators([TEST_INDICATOR_NAMES[1]])
Expand All @@ -94,40 +97,41 @@ describe('using a Scatter chart', () => {
//expectStoreCurrentColumnsToHaveLength(1) // FIXME: Store is always in default state
expectVerticalToContainDimensionLabel(TEST_INDICATOR_NAMES[0])
expectHorizontalToContainDimensionLabel(TEST_INDICATOR_NAMES[1])
})
it('selects org unit level Facility', () => {

cy.log('selects org unit level Facility')
const TEST_ORG_UNIT_LEVEL = 'Facility'
openDimension(DIMENSION_ID_ORGUNIT)
expectOrgUnitDimensionModalToBeVisible()
deselectUserOrgUnit('User organisation unit')
expectOrgUnitDimensionToNotBeLoading()
// FIXME this selection causes a analytics request that takes too long on test instances
// FIXME: this selection causes a analytics request that takes too long on test instances
//selectOrgUnitTreeItem('Sierra Leone')
selectOrgUnitTreeItem('Bo')
selectOrgUnitTreeItem('Bombali')
toggleOrgUnitLevel(TEST_ORG_UNIT_LEVEL)
expectOrgUnitDimensionModalToBeVisible()
clickDimensionModalUpdateButton()
expectVisualizationToBeVisible(VIS_TYPE_SCATTER)
})
it('Data is locked to Vertical', () => {

cy.log('Data is locked to Vertical')
expectDimensionOnAxisToHaveLockIcon(DIMENSION_ID_DATA, 'Vertical')
})
it('Data is locked to Horizontal', () => {

cy.log('Data is locked to Horizontal')
expectDimensionOnAxisToHaveLockIcon(DIMENSION_ID_DATA, 'Horizontal')
})
it('Org units is locked to Points', () => {

cy.log('Org units is locked to Points')
expectDimensionOnAxisToHaveLockIcon(DIMENSION_ID_ORGUNIT, AXIS_ID_ROWS)
})
it('swaps vertical with horizontal', () => {

cy.log('swaps vertical with horizontal')
openContextMenu('VERTICAL')
clickContextMenuSwap('VERTICAL', 'HORIZONTAL')
clickMenuBarUpdateButton()
expectVisualizationToBeVisible(VIS_TYPE_SCATTER)
expectAppToNotBeLoading()
expectVerticalToContainDimensionLabel(TEST_INDICATOR_NAMES[1])
expectHorizontalToContainDimensionLabel(TEST_INDICATOR_NAMES[0])
})
it('adds a second item to horizontal and displays warning messages', () => {

cy.log('adds a second item to horizontal and displays warning messages')
openDimensionOnAxis(DIMENSION_ID_DATA, 'Horizontal')
selectIndicators([TEST_INDICATOR_NAMES[2]])
expectDataDimensionModalWarningToContain(
Expand All @@ -139,23 +143,27 @@ describe('using a Scatter chart', () => {
).id
)
clickDimensionModalUpdateButton()
expectVisualizationToBeVisible(VIS_TYPE_SCATTER)
expectAppToNotBeLoading()
expectDimensionOnAxisToHaveWarningIcon(DIMENSION_ID_DATA, 'Horizontal')
})
it('saves and only displays 1 horizontal item', () => {

cy.log('saves and only displays 1 horizontal item')
saveNewAO(TEST_VIS_NAME)
expectVisualizationToBeVisible(VIS_TYPE_SCATTER)
expectAppToNotBeLoading()
expectVerticalToContainDimensionLabel(TEST_INDICATOR_NAMES[1])
expectHorizontalToContainDimensionLabel(TEST_INDICATOR_NAMES[0])
})
it('swaps vertical with horizontal', () => {

cy.log('swaps vertical with horizontal')
openContextMenu('HORIZONTAL')
clickContextMenuSwap('HORIZONTAL', 'VERTICAL')
clickMenuBarUpdateButton()
expectVisualizationToBeVisible(VIS_TYPE_SCATTER)
expectAppToNotBeLoading()
expectVerticalToContainDimensionLabel(TEST_INDICATOR_NAMES[0])
expectHorizontalToContainDimensionLabel(TEST_INDICATOR_NAMES[1])
})
it('Options -> Axes -> sets min/max range', () => {

cy.log('Options -> Axes -> sets min/max range')
const TEST_AXES = [
{ axis: 'RANGE_0', label: 'Vertical (y) axis', min: 50, max: 150 },
{
Expand All @@ -177,24 +185,24 @@ describe('using a Scatter chart', () => {
expectWindowConfigYAxisToHaveRangeMaxValue(TEST_AXES[0].max)
expectWindowConfigXAxisToHaveRangeMinValue(TEST_AXES[1].min)
expectWindowConfigXAxisToHaveRangeMaxValue(TEST_AXES[1].max)
})
it('Options -> Outliers -> enables outliers', () => {

cy.log('Options -> Outliers -> enables outliers')
openOptionsModal(OPTIONS_TAB_OUTLIERS)
checkOutliersCheckbox()
// TODO: Set more outlier options
clickOptionsModalUpdateButton()
expectVisualizationToBeVisible(VIS_TYPE_SCATTER)
// TODO: Intercept the data returned to simplify / standardise it, then check that the $config has the correct data
})
it('saves and displays items in the correct places', () => {

cy.log('saves and displays items in the correct places')
saveExistingAO()
expectAppToNotBeLoading()
expectVisualizationToBeVisible(VIS_TYPE_SCATTER)
expectVerticalToContainDimensionLabel(TEST_INDICATOR_NAMES[0])
expectHorizontalToContainDimensionLabel(TEST_INDICATOR_NAMES[1])
})
// TODO: Open outlier options again and check that everything was saved correctly
it('deletes saved scatter AO', () => {

// TODO: Open outlier options again and check that everything was saved correctly
cy.log('deletes saved scatter AO')
deleteAO()
expectStartScreenToBeVisible()
expectRouteToBeEmpty()
Expand Down

0 comments on commit ddfae31

Please sign in to comment.