From 0eccf9372c6665ddc0f4bbaea460ad2d21723b2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Henrik=20=C3=98verland?= Date: Mon, 5 Aug 2024 10:36:07 +0200 Subject: [PATCH] feat: pivot table as default vis type in DV (DHIS2-15833) (#3159) * 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 --- cypress/elements/visualizationTypeSelector.js | 2 +- .../integration/dimensions/calculations.cy.js | 8 ++++- cypress/integration/dimensions/dynamic.cy.js | 8 ++++- cypress/integration/dimensions/orgUnit.cy.js | 5 ++- cypress/integration/drillDown.cy.js | 5 +-- cypress/integration/options/axes.cy.js | 11 +++++- cypress/integration/options/fontStyles.cy.js | 8 ++++- cypress/integration/options/legend.cy.js | 36 +++++++++++-------- cypress/integration/options/lines.cy.js | 8 ++++- package.json | 2 +- yarn.lock | 8 ++--- 11 files changed, 72 insertions(+), 29 deletions(-) diff --git a/cypress/elements/visualizationTypeSelector.js b/cypress/elements/visualizationTypeSelector.js index 3625e9e372..6620e30e20 100644 --- a/cypress/elements/visualizationTypeSelector.js +++ b/cypress/elements/visualizationTypeSelector.js @@ -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() diff --git a/cypress/integration/dimensions/calculations.cy.js b/cypress/integration/dimensions/calculations.cy.js index cb3430fc92..4e1d9f3621 100644 --- a/cypress/integration/dimensions/calculations.cy.js +++ b/cypress/integration/dimensions/calculations.cy.js @@ -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, @@ -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?*' @@ -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) diff --git a/cypress/integration/dimensions/dynamic.cy.js b/cypress/integration/dimensions/dynamic.cy.js index d632357538..d999d9770c 100644 --- a/cypress/integration/dimensions/dynamic.cy.js +++ b/cypress/integration/dimensions/dynamic.cy.js @@ -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 { @@ -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 = { @@ -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() diff --git a/cypress/integration/dimensions/orgUnit.cy.js b/cypress/integration/dimensions/orgUnit.cy.js index 1acf9f433a..c97074bd80 100644 --- a/cypress/integration/dimensions/orgUnit.cy.js +++ b/cypress/integration/dimensions/orgUnit.cy.js @@ -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 { @@ -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' @@ -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() diff --git a/cypress/integration/drillDown.cy.js b/cypress/integration/drillDown.cy.js index 139b5e5f99..24f3857464 100644 --- a/cypress/integration/drillDown.cy.js +++ b/cypress/integration/drillDown.cy.js @@ -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, @@ -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() @@ -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]) diff --git a/cypress/integration/options/axes.cy.js b/cypress/integration/options/axes.cy.js index 8b42ce1868..8baedd1415 100644 --- a/cypress/integration/options/axes.cy.js +++ b/cypress/integration/options/axes.cy.js @@ -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, @@ -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' @@ -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() @@ -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() @@ -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() @@ -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, diff --git a/cypress/integration/options/fontStyles.cy.js b/cypress/integration/options/fontStyles.cy.js index 366f519265..7e1021e1c6 100644 --- a/cypress/integration/options/fontStyles.cy.js +++ b/cypress/integration/options/fontStyles.cy.js @@ -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, @@ -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, @@ -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() diff --git a/cypress/integration/options/legend.cy.js b/cypress/integration/options/legend.cy.js index 4246eca033..42015e3aaf 100644 --- a/cypress/integration/options/legend.cy.js +++ b/cypress/integration/options/legend.cy.js @@ -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, @@ -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() @@ -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() @@ -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() @@ -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() @@ -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() @@ -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() @@ -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) @@ -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() @@ -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) @@ -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() @@ -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) @@ -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) @@ -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) @@ -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() @@ -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) @@ -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() @@ -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() @@ -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() @@ -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() diff --git a/cypress/integration/options/lines.cy.js b/cypress/integration/options/lines.cy.js index 3a332aeb84..e9650c5f5f 100644 --- a/cypress/integration/options/lines.cy.js +++ b/cypress/integration/options/lines.cy.js @@ -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, @@ -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 { @@ -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() diff --git a/package.json b/package.json index 631eef38f0..d6159fe93d 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "typescript": "^4.8.4" }, "dependencies": { - "@dhis2/analytics": "^26.7.6", + "@dhis2/analytics": "^26.8.0", "@dhis2/app-runtime": "^3.7.0", "@dhis2/app-runtime-adapter-d2": "^1.1.0", "@dhis2/app-service-datastore": "^1.0.0-beta.3", diff --git a/yarn.lock b/yarn.lock index 05279306c6..93d82e8376 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2029,10 +2029,10 @@ classnames "^2.3.1" prop-types "^15.7.2" -"@dhis2/analytics@^26.7.6": - version "26.7.6" - resolved "https://registry.yarnpkg.com/@dhis2/analytics/-/analytics-26.7.6.tgz#9325a4f0d84dec665633720f4fa66e2daba70ccb" - integrity sha512-aArOXWIXHb+hosC95zXFppYv+0haMxQcoaDoRTMkQp88emEIXJ9ekogRvx7FfKf1nFD7PSCJnPotKvfVBA2wtQ== +"@dhis2/analytics@^26.8.0": + version "26.8.0" + resolved "https://registry.yarnpkg.com/@dhis2/analytics/-/analytics-26.8.0.tgz#8e8383feef65a4f64b094077fd284af1151ad2b5" + integrity sha512-P8mHq1AV5RoXJQZYxzjl3vRRUIlZzLoKpkUVTn/5Ww+Z/Y3smY9YHdOceHK+9ERF1XqZyRhlCLxN8M56u+jR+g== dependencies: "@dhis2/multi-calendar-dates" "^1.2.2" "@dnd-kit/core" "^6.0.7"