Skip to content

Commit

Permalink
feat: pivot table as default vis type in DV (DHIS2-15833) (#3159)
Browse files Browse the repository at this point in the history
* feat: pivot table as default vis type in DV

* test: make tests expect pivot table as vis type

* chore: unused imports

* test: update tests

* test: update tests

* test: update tests

* test: update tests

* chore: import order

* style: imports

* test: update tests

* test: update tests

* test: update tests
  • Loading branch information
janhenrikoverland authored Aug 5, 2024
1 parent 4c08077 commit 0eccf93
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 29 deletions.
2 changes: 1 addition & 1 deletion cypress/elements/visualizationTypeSelector.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const vstCardEl = 'visualization-type-selector-card'
const vstButtonEl = 'visualization-type-selector-button'
const vstButtonTextEl = 'visualization-type-selector-currently-selected-text'
const defaultVisTypeName = 'Column'
const defaultVisTypeName = 'Pivot table'

export const clickVisTypeSelector = () => cy.getBySel(vstButtonEl).click()

Expand Down
8 changes: 7 additions & 1 deletion cypress/integration/dimensions/calculations.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { DIMENSION_ID_DATA, VIS_TYPE_COLUMN } from '@dhis2/analytics'
import {
DIMENSION_ID_DATA,
VIS_TYPE_COLUMN,
getDisplayNameByVisType,
} from '@dhis2/analytics'
import {
clickCancelButton,
clickCheckFormulaButton,
Expand Down Expand Up @@ -38,6 +42,7 @@ import {
import { openDimension } from '../../elements/dimensionsPanel.js'
import { saveNewAO } from '../../elements/fileMenu/save.js'
import { goToStartPage } from '../../elements/startScreen.js'
import { changeVisType } from '../../elements/visualizationTypeSelector.js'

const PAGE_SIZE = 50
const DATA_ELEMENTS_URL = '**/dataElements?*'
Expand All @@ -47,6 +52,7 @@ const dataChipEl = 'layout-chip-dx'
describe('Calculations', () => {
beforeEach(() => {
goToStartPage()
changeVisType(getDisplayNameByVisType(VIS_TYPE_COLUMN))
})
it('initial state loads correctly', () => {
openDimension(DIMENSION_ID_DATA)
Expand Down
8 changes: 7 additions & 1 deletion cypress/integration/dimensions/dynamic.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { DIMENSION_ID_DATA, VIS_TYPE_COLUMN } from '@dhis2/analytics'
import {
DIMENSION_ID_DATA,
VIS_TYPE_COLUMN,
getDisplayNameByVisType,
} from '@dhis2/analytics'
import { expectVisualizationToBeVisible } from '../../elements/chart.js'
import { expectAppToNotBeLoading } from '../../elements/common.js'
import {
Expand All @@ -20,6 +24,7 @@ import {
expectDimensionToHaveItemAmount,
} from '../../elements/layout.js'
import { goToStartPage } from '../../elements/startScreen.js'
import { changeVisType } from '../../elements/visualizationTypeSelector.js'
import { expectWindowConfigSeriesToHaveLength } from '../../utils/window.js'

const TEST_DYNAMIC_DIMENSION = {
Expand All @@ -32,6 +37,7 @@ describe(`Dynamic dimension - ${TEST_DYNAMIC_DIMENSION.name}`, () => {
it('can add and remove items, which persist after saving', () => {
cy.log('navigates to the start page and adds a data item')
goToStartPage()
changeVisType(getDisplayNameByVisType(VIS_TYPE_COLUMN))
openDimension(DIMENSION_ID_DATA)
selectDataElements(['ANC 2nd visit'])
clickDimensionModalUpdateButton()
Expand Down
5 changes: 4 additions & 1 deletion cypress/integration/dimensions/orgUnit.cy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {
DIMENSION_ID_DATA,
VIS_TYPE_COLUMN,
DIMENSION_ID_ORGUNIT,
AXIS_ID_COLUMNS,
VIS_TYPE_COLUMN,
getDisplayNameByVisType,
} from '@dhis2/analytics'
import { expectVisualizationToBeVisible } from '../../elements/chart.js'
import {
Expand Down Expand Up @@ -30,6 +31,7 @@ import {
} from '../../elements/layout.js'
import { clickMenuBarUpdateButton } from '../../elements/menuBar.js'
import { goToStartPage } from '../../elements/startScreen.js'
import { changeVisType } from '../../elements/visualizationTypeSelector.js'
import { TEST_DATA_ELEMENTS } from '../../utils/data.js'
import { getRandomArrayItem } from '../../utils/random.js'
import { expectWindowConfigSeriesToHaveLength } from '../../utils/window.js'
Expand All @@ -41,6 +43,7 @@ describe(`Org unit dimension`, () => {
const TEST_DEFAULT_ORG_UNIT = 'User organisation unit'
it('navigates to the start page, adds a data item, moves Org Unit to Series', () => {
goToStartPage()
changeVisType(getDisplayNameByVisType(VIS_TYPE_COLUMN))
openDimension(DIMENSION_ID_DATA)
selectDataElements([TEST_DATA_ELEMENT_NAME])
clickDimensionModalHideButton()
Expand Down
5 changes: 3 additions & 2 deletions cypress/integration/drillDown.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
DIMENSION_ID_ORGUNIT,
AXIS_ID_FILTERS,
AXIS_ID_ROWS,
visTypeDisplayNames,
VIS_TYPE_PIVOT_TABLE,
getDisplayNameByVisType,
} from '@dhis2/analytics'
import {
clickChartItem,
Expand Down Expand Up @@ -43,6 +43,7 @@ import { TEST_INDICATORS } from '../utils/data.js'
describe('Drill-down: Column', () => {
it('navigates to the start page and adds a data item', () => {
goToStartPage()
changeVisType(getDisplayNameByVisType(VIS_TYPE_COLUMN))
openDimension(DIMENSION_ID_DATA)
selectIndicators([TEST_INDICATORS[2].name])
clickDimensionModalUpdateButton()
Expand Down Expand Up @@ -87,7 +88,7 @@ describe('Drill-down: Column', () => {
describe('Drill-down: Pivot table', () => {
it('navigates to the start page, changes vis type to Pivot table and adds a data item', () => {
goToStartPage()
changeVisType(visTypeDisplayNames[VIS_TYPE_PIVOT_TABLE])
changeVisType(getDisplayNameByVisType(VIS_TYPE_PIVOT_TABLE))
clickMenuBarUpdateButton()
openDimension(DIMENSION_ID_DATA)
selectIndicators([TEST_INDICATORS[2].name])
Expand Down
11 changes: 10 additions & 1 deletion cypress/integration/options/axes.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { DIMENSION_ID_DATA, VIS_TYPE_COLUMN } from '@dhis2/analytics'
import {
DIMENSION_ID_DATA,
VIS_TYPE_COLUMN,
getDisplayNameByVisType,
} from '@dhis2/analytics'
import {
expectVisualizationToBeVisible,
expectChartTitleToBeVisible,
Expand Down Expand Up @@ -27,6 +31,7 @@ import {
setAxisStepsValue,
} from '../../elements/optionsModal/index.js'
import { goToStartPage } from '../../elements/startScreen.js'
import { changeVisType } from '../../elements/visualizationTypeSelector.js'
import { CONFIG_DEFAULT_VERTICAL_AXIS_TITLE } from '../../utils/config.js'
import { TEST_DATA_ELEMENTS } from '../../utils/data.js'
import { generateRandomNumber, getRandomArrayItem } from '../../utils/random.js'
Expand All @@ -50,6 +55,7 @@ describe('Options - Vertical axis', () => {
const TEST_TITLE = 'VT'
it('navigates to the start page and add a data item', () => {
goToStartPage()
changeVisType(getDisplayNameByVisType(VIS_TYPE_COLUMN))
openDimension(DIMENSION_ID_DATA)
selectDataElements([TEST_DATA_ELEMENT_NAME])
clickDimensionModalUpdateButton()
Expand Down Expand Up @@ -131,6 +137,7 @@ describe('Options - Horizontal axis', () => {
const TEST_TAB = 'Horizontal (x) axis'
it('navigates to the start page and add a data item', () => {
goToStartPage()
changeVisType(getDisplayNameByVisType(VIS_TYPE_COLUMN))
openDimension(DIMENSION_ID_DATA)
selectDataElements([TEST_DATA_ELEMENT_NAME])
clickDimensionModalUpdateButton()
Expand Down Expand Up @@ -173,6 +180,7 @@ describe('Options - Horizontal axis', () => {
describe('Options - Auto-generated axis title', () => {
it('navigates to the start page and add a data item', () => {
goToStartPage()
changeVisType(getDisplayNameByVisType(VIS_TYPE_COLUMN))
openDimension(DIMENSION_ID_DATA)
selectDataElements([TEST_DATA_ELEMENT_NAME])
clickDimensionModalUpdateButton()
Expand Down Expand Up @@ -223,6 +231,7 @@ describe('Options - Auto-generated axis title', () => {
describe('Multi items - multi axis', () => {
it('navigates to the start page and adds two data items', () => {
goToStartPage()
changeVisType(getDisplayNameByVisType(VIS_TYPE_COLUMN))
openDimension(DIMENSION_ID_DATA)
selectDataElements([
TEST_DATA_ELEMENT_NAME,
Expand Down
8 changes: 7 additions & 1 deletion cypress/integration/options/fontStyles.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { DIMENSION_ID_DATA, VIS_TYPE_COLUMN } from '@dhis2/analytics'
import {
DIMENSION_ID_DATA,
VIS_TYPE_COLUMN,
getDisplayNameByVisType,
} from '@dhis2/analytics'
import {
expectVisualizationToBeVisible,
expectChartTitleToBeVisible,
Expand Down Expand Up @@ -32,6 +36,7 @@ import {
changeColor,
} from '../../elements/optionsModal/index.js'
import { goToStartPage } from '../../elements/startScreen.js'
import { changeVisType } from '../../elements/visualizationTypeSelector.js'
import {
CONFIG_DEFAULT_SUBTITLE,
CONFIG_DEFAULT_TITLE,
Expand Down Expand Up @@ -108,6 +113,7 @@ const setFontStyleOptions = ({
describe('Options - Font styles', () => {
it('navigates to the start page and adds a data item', () => {
goToStartPage()
changeVisType(getDisplayNameByVisType(VIS_TYPE_COLUMN))
openDimension(DIMENSION_ID_DATA)
selectDataElements([TEST_DATA_ELEMENT_NAME])
clickDimensionModalUpdateButton()
Expand Down
36 changes: 21 additions & 15 deletions cypress/integration/options/legend.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import {
VIS_TYPE_PIVOT_TABLE,
VIS_TYPE_STACKED_COLUMN,
VIS_TYPE_LINE,
visTypeDisplayNames,
DIMENSION_ID_PERIOD,
AXIS_ID_COLUMNS,
VIS_TYPE_AREA,
AXIS_ID_ROWS,
getDisplayNameByVisType,
} from '@dhis2/analytics'
import {
expectChartTitleToBeVisible,
Expand Down Expand Up @@ -96,6 +96,7 @@ describe('Options - Legend', () => {
it('applies different styles of legend to a Column chart', () => {
cy.log('navigates to the start page and add data items')
goToStartPage()
changeVisType(getDisplayNameByVisType(VIS_TYPE_COLUMN))
openDimension(DIMENSION_ID_DATA)
selectIndicators(TEST_ITEMS.map((item) => item.name))
clickDimensionModalUpdateButton()
Expand Down Expand Up @@ -169,7 +170,7 @@ describe('Options - Legend', () => {

cy.log('navigates to the start page and adds data items')
goToStartPage()
changeVisType(visTypeDisplayNames[VIS_TYPE_SINGLE_VALUE])
changeVisType(getDisplayNameByVisType(VIS_TYPE_SINGLE_VALUE))
openDimension(DIMENSION_ID_DATA)
selectIndicators([TEST_ITEM.name])
clickDimensionModalUpdateButton()
Expand Down Expand Up @@ -333,7 +334,7 @@ describe('Options - Legend', () => {

cy.log('navigates to the start page and adds data items')
goToStartPage()
changeVisType(visTypeDisplayNames[VIS_TYPE_GAUGE])
changeVisType(getDisplayNameByVisType(VIS_TYPE_GAUGE))
openDimension(DIMENSION_ID_DATA)
selectIndicators([TEST_ITEM.name])
clickDimensionModalUpdateButton()
Expand Down Expand Up @@ -399,7 +400,7 @@ describe('Options - Legend', () => {
it('applies different styles of legend to a Stacked Column chart', () => {
cy.log('navigates to the start page and adds data items')
goToStartPage()
changeVisType(visTypeDisplayNames[VIS_TYPE_STACKED_COLUMN])
changeVisType(getDisplayNameByVisType(VIS_TYPE_STACKED_COLUMN))
openDimension(DIMENSION_ID_DATA)
selectIndicators(TEST_ITEMS.map((item) => item.name))
clickDimensionModalUpdateButton()
Expand Down Expand Up @@ -464,7 +465,7 @@ describe('Options - Legend', () => {

cy.log('navigates to the start page and adds data items')
goToStartPage()
changeVisType(visTypeDisplayNames[VIS_TYPE_PIVOT_TABLE])
changeVisType(getDisplayNameByVisType(VIS_TYPE_PIVOT_TABLE))
openDimension(DIMENSION_ID_DATA)
selectIndicators([TEST_ITEM.name])
clickDimensionModalUpdateButton()
Expand Down Expand Up @@ -559,7 +560,7 @@ describe('Options - Legend', () => {
'navigates to the start page and adds data items and create Pivot'
)
goToStartPage()
changeVisType(visTypeDisplayNames[VIS_TYPE_PIVOT_TABLE])
changeVisType(getDisplayNameByVisType(VIS_TYPE_PIVOT_TABLE))
openDimension(DIMENSION_ID_DATA)
selectIndicators([TEST_ITEM.name])
clickDimensionModalUpdateButton()
Expand Down Expand Up @@ -588,7 +589,7 @@ describe('Options - Legend', () => {
})

cy.log('changes vis type to Gauge')
changeVisType(visTypeDisplayNames[VIS_TYPE_GAUGE])
changeVisType(getDisplayNameByVisType(VIS_TYPE_GAUGE))
clickMenuBarUpdateButton()
expectVisualizationToBeVisible(VIS_TYPE_GAUGE)

Expand All @@ -609,7 +610,7 @@ describe('Options - Legend', () => {

cy.log('navigates to the start page and adds data items')
goToStartPage()
changeVisType(visTypeDisplayNames[VIS_TYPE_PIVOT_TABLE])
changeVisType(getDisplayNameByVisType(VIS_TYPE_PIVOT_TABLE))
openDimension(DIMENSION_ID_DATA)
selectIndicators([TEST_ITEM.name])
clickDimensionModalUpdateButton()
Expand All @@ -636,7 +637,7 @@ describe('Options - Legend', () => {
})

cy.log('changes vis type to Single value')
changeVisType(visTypeDisplayNames[VIS_TYPE_SINGLE_VALUE])
changeVisType(getDisplayNameByVisType(VIS_TYPE_SINGLE_VALUE))
clickMenuBarUpdateButton()
expectVisualizationToBeVisible(VIS_TYPE_SINGLE_VALUE)

Expand All @@ -650,9 +651,10 @@ describe('Options - Legend', () => {
expectLegendDisplayStrategyToBeFixed()
})

it('applies the legend key setttings when vis type changes: Column -> Pivot table -> Gauge -> Single value', () => {
it('applies the legend key settings when vis type changes: Column -> Pivot table -> Gauge -> Single value', () => {
cy.log('navigates to the start page and adds data items')
goToStartPage()
changeVisType(getDisplayNameByVisType(VIS_TYPE_COLUMN))
openDimension(DIMENSION_ID_DATA)
selectIndicators(TEST_ITEMS.map((item) => item.name))
clickDimensionModalUpdateButton()
Expand Down Expand Up @@ -680,7 +682,7 @@ describe('Options - Legend', () => {
expectLegedKeyItemAmountToBe(TEST_ITEMS.length)

cy.log('changes vis type to Pivot table')
changeVisType(visTypeDisplayNames[VIS_TYPE_PIVOT_TABLE])
changeVisType(getDisplayNameByVisType(VIS_TYPE_PIVOT_TABLE))
clickMenuBarUpdateButton()
expectVisualizationToBeVisible(VIS_TYPE_PIVOT_TABLE)

Expand All @@ -701,7 +703,7 @@ describe('Options - Legend', () => {
expectLegendKeyToBeHidden()

cy.log('changes vis type to Gauge')
changeVisType(visTypeDisplayNames[VIS_TYPE_GAUGE])
changeVisType(getDisplayNameByVisType(VIS_TYPE_GAUGE))
clickMenuBarUpdateButton()
expectVisualizationToBeVisible(VIS_TYPE_GAUGE)

Expand All @@ -720,7 +722,7 @@ describe('Options - Legend', () => {
expectLegedKeyItemAmountToBe(1)

cy.log('changes vis type to Single value')
changeVisType(visTypeDisplayNames[VIS_TYPE_SINGLE_VALUE])
changeVisType(getDisplayNameByVisType(VIS_TYPE_SINGLE_VALUE))
clickMenuBarUpdateButton()
expectVisualizationToBeVisible(VIS_TYPE_SINGLE_VALUE)

Expand All @@ -741,6 +743,7 @@ describe('Options - Legend', () => {
it('does not apply non-applicable options when Column switched to Area', () => {
cy.log('navigates to the start page and adds data items')
goToStartPage()
changeVisType(getDisplayNameByVisType(VIS_TYPE_COLUMN))
openDimension(DIMENSION_ID_DATA)
selectIndicators(TEST_ITEMS.map((item) => item.name))
clickDimensionModalUpdateButton()
Expand All @@ -763,7 +766,7 @@ describe('Options - Legend', () => {
)

cy.log('changes vis type to Area')
changeVisType(visTypeDisplayNames[VIS_TYPE_AREA])
changeVisType(getDisplayNameByVisType(VIS_TYPE_AREA))
clickMenuBarUpdateButton()
expectVisualizationToBeVisible(VIS_TYPE_AREA)

Expand All @@ -786,7 +789,7 @@ describe('Options - Legend', () => {
it('does not enable legend options for Line chart', () => {
cy.log('navigates to the start page and adds data items')
goToStartPage()
changeVisType(visTypeDisplayNames[VIS_TYPE_LINE])
changeVisType(getDisplayNameByVisType(VIS_TYPE_LINE))
openDimension(DIMENSION_ID_DATA)
selectIndicators(TEST_ITEMS.map((item) => item.name))
clickDimensionModalUpdateButton()
Expand All @@ -810,6 +813,7 @@ describe('Options - Legend', () => {
it('changes legend from per data item to fixed strategy for Column chart', () => {
cy.log('navigates to the start page and adds data items')
goToStartPage()
changeVisType(getDisplayNameByVisType(VIS_TYPE_COLUMN))
openDimension(DIMENSION_ID_DATA)
selectIndicators(TEST_ITEMS.map((item) => item.name))
clickDimensionModalUpdateButton()
Expand Down Expand Up @@ -844,6 +848,7 @@ describe('Options - Legend', () => {
'navigates to the start page and adds data items, legend and legend key'
)
goToStartPage()
changeVisType(getDisplayNameByVisType(VIS_TYPE_COLUMN))
openDimension(DIMENSION_ID_DATA)
selectIndicators([TEST_ITEM.name])
clickDimensionModalUpdateButton()
Expand Down Expand Up @@ -915,6 +920,7 @@ describe('Options - Legend', () => {
'navigates to the start page and adds data items, legend and legend key'
)
goToStartPage()
changeVisType(getDisplayNameByVisType(VIS_TYPE_COLUMN))
openDimension(DIMENSION_ID_DATA)
selectIndicators(TEST_ITEMS.map((item) => item.name))
clickDimensionModalUpdateButton()
Expand Down
8 changes: 7 additions & 1 deletion cypress/integration/options/lines.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { DIMENSION_ID_DATA, VIS_TYPE_COLUMN } from '@dhis2/analytics'
import {
DIMENSION_ID_DATA,
VIS_TYPE_COLUMN,
getDisplayNameByVisType,
} from '@dhis2/analytics'
import {
expectVisualizationToBeVisible,
expectChartTitleToBeVisible,
Expand All @@ -16,6 +20,7 @@ import {
selectTrendLineType,
} from '../../elements/optionsModal/index.js'
import { goToStartPage } from '../../elements/startScreen.js'
import { changeVisType } from '../../elements/visualizationTypeSelector.js'
import { CONFIG_DEFAULT_TREND_LINE } from '../../utils/config.js'
import { TEST_DATA_ELEMENTS } from '../../utils/data.js'
import {
Expand All @@ -30,6 +35,7 @@ const TEST_DATA_ELEMENT_NAMES = TEST_DATA_ELEMENTS.slice(2, 4).map(
describe('Options - Lines', () => {
it('navigates to the start page and adds data items', () => {
goToStartPage()
changeVisType(getDisplayNameByVisType(VIS_TYPE_COLUMN))
openDimension(DIMENSION_ID_DATA)
selectDataElements(TEST_DATA_ELEMENT_NAMES)
clickDimensionModalUpdateButton()
Expand Down
Loading

0 comments on commit 0eccf93

Please sign in to comment.