From 3507b806898a30b6c2c9b9ea03fdacf58a5c4d21 Mon Sep 17 00:00:00 2001 From: Edoardo Sabadelli Date: Thu, 2 May 2024 11:42:51 +0200 Subject: [PATCH 1/3] fix: use alpha version of analytics with the fix --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 2ff9121ea5..70405df96a 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "typescript": "^4.8.4" }, "dependencies": { - "@dhis2/analytics": "^26.6.5", + "@dhis2/analytics": "999.99.9-pt-crash-alpha.1", "@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 0cc8819006..1337ecd23d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2028,10 +2028,10 @@ classnames "^2.3.1" prop-types "^15.7.2" -"@dhis2/analytics@^26.6.5": - version "26.6.5" - resolved "https://registry.yarnpkg.com/@dhis2/analytics/-/analytics-26.6.5.tgz#44ee29a279c37f3969096d859bc0f07d953e3f42" - integrity sha512-ob6kNEEkIAC50RtKuUZWi8Y04uwsPHK/EiYhzxZkSOdS5wFm8X+88KZrD//fILXQjwMhJvl/4+F/T0qVxOF/jQ== +"@dhis2/analytics@999.99.9-pt-crash-alpha.1": + version "999.99.9-pt-crash-alpha.1" + resolved "https://registry.yarnpkg.com/@dhis2/analytics/-/analytics-999.99.9-pt-crash-alpha.1.tgz#2cf63e472899154e88ff581185c75ac92f712080" + integrity sha512-KVc269FcWX7Hcu3ZPLEQgqU7W1sgQxwFTB05e4WuuFwFoOx/kNMJVSaucteIU1Se/ImZXHamoNj4Fer1ynL1kA== dependencies: "@dhis2/d2-ui-rich-text" "^7.4.1" "@dhis2/multi-calendar-dates" "1.0.0" From a34ea58b1040f0d98fb75679438515b74bb69623 Mon Sep 17 00:00:00 2001 From: Edoardo Sabadelli Date: Fri, 3 May 2024 10:24:52 +0200 Subject: [PATCH 2/3] test: add regression test for DHIS2-17297 --- cypress/elements/pivotTable.js | 3 + cypress/integration/options/totals.cy.js | 82 ++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 cypress/integration/options/totals.cy.js diff --git a/cypress/elements/pivotTable.js b/cypress/elements/pivotTable.js index 3b41d3982d..4463645e36 100644 --- a/cypress/elements/pivotTable.js +++ b/cypress/elements/pivotTable.js @@ -1,6 +1,9 @@ const valueCellEl = 'visualization-value-cell' const headerCellEl = 'visualization-column-header' +export const expectTableToBeVisible = () => + cy.get('.pivot-table-container').should('have.length', 1).and('be.visible') + export const clickTableValueCell = (index) => cy.getBySel(valueCellEl).eq(index).click() diff --git a/cypress/integration/options/totals.cy.js b/cypress/integration/options/totals.cy.js new file mode 100644 index 0000000000..81d5adfe8e --- /dev/null +++ b/cypress/integration/options/totals.cy.js @@ -0,0 +1,82 @@ +import { + AXIS_ID_COLUMNS, + AXIS_ID_ROWS, + DIMENSION_ID_DATA, + DIMENSION_ID_PERIOD, + VIS_TYPE_PIVOT_TABLE, + visTypeDisplayNames, +} from '@dhis2/analytics' +import { checkCheckbox } from '../../elements/common.js' +import { + clickDimensionModalHideButton, + clickDimensionModalUpdateButton, + expectDimensionModalToBeVisible, + selectAllItemsByButton, + selectDataElements, + selectFixedPeriods, + unselectAllItemsByButton, +} from '../../elements/dimensionModal/index.js' +import { + clickContextMenuAdd, + openContextMenu as openDimPanelContextMenu, + openDimension, +} from '../../elements/dimensionsPanel.js' +import { clickContextMenuMove, openContextMenu } from '../../elements/layout.js' +import { openOptionsModal } from '../../elements/menuBar.js' +import { + OPTIONS_TAB_DATA, + clickOptionsModalHideButton, +} from '../../elements/optionsModal/index.js' +import { + colTotalsOptionEl, + expectColumnsTotalsToBeChecked, +} from '../../elements/optionsModal/totals.js' +import { expectTableToBeVisible } from '../../elements/pivotTable.js' +import { goToStartPage } from '../../elements/startScreen.js' +import { changeVisType } from '../../elements/visualizationTypeSelector.js' +import { TEST_CUSTOM_DIMENSIONS } from '../../utils/data.js' + +const AREA_DIMENSION = TEST_CUSTOM_DIMENSIONS.find((dim) => dim.name === 'Area') + +describe('Options - Column totals', () => { + describe('Regression test for DHIS2-17297', () => { + it('does not crash', () => { + goToStartPage() + changeVisType(visTypeDisplayNames[VIS_TYPE_PIVOT_TABLE]) + + openOptionsModal(OPTIONS_TAB_DATA) + checkCheckbox(colTotalsOptionEl) + + expectColumnsTotalsToBeChecked() + + clickOptionsModalHideButton() + + openContextMenu(DIMENSION_ID_DATA) + clickContextMenuMove(DIMENSION_ID_DATA, AXIS_ID_ROWS) + openContextMenu(DIMENSION_ID_PERIOD) + clickContextMenuMove(DIMENSION_ID_PERIOD, AXIS_ID_COLUMNS) + + openDimension(DIMENSION_ID_DATA) + selectDataElements(['ART enrollment stage 1']) + clickDimensionModalHideButton() + + const year = new Date().getFullYear().toString() + openDimension(DIMENSION_ID_PERIOD) + unselectAllItemsByButton() + selectFixedPeriods( + [`May ${year}`, `June ${year}`, `July ${year}`], + 'Monthly' + ) + clickDimensionModalHideButton() + + openDimPanelContextMenu(AREA_DIMENSION.id) + clickContextMenuAdd(AREA_DIMENSION.id, AXIS_ID_ROWS) + expectDimensionModalToBeVisible(AREA_DIMENSION.id) + selectAllItemsByButton() + + clickDimensionModalUpdateButton() + + expectTableToBeVisible() + }) + }) +}) From 1c8bb73fe83c6a93084e153c15815b693f746298 Mon Sep 17 00:00:00 2001 From: Edoardo Sabadelli Date: Mon, 6 May 2024 13:36:00 +0200 Subject: [PATCH 3/3] fix: bump analytics dep for DHIS2-17297 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 70405df96a..d0f56dd4f2 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "typescript": "^4.8.4" }, "dependencies": { - "@dhis2/analytics": "999.99.9-pt-crash-alpha.1", + "@dhis2/analytics": "^26.6.8", "@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 1337ecd23d..4b576076b7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2028,10 +2028,10 @@ classnames "^2.3.1" prop-types "^15.7.2" -"@dhis2/analytics@999.99.9-pt-crash-alpha.1": - version "999.99.9-pt-crash-alpha.1" - resolved "https://registry.yarnpkg.com/@dhis2/analytics/-/analytics-999.99.9-pt-crash-alpha.1.tgz#2cf63e472899154e88ff581185c75ac92f712080" - integrity sha512-KVc269FcWX7Hcu3ZPLEQgqU7W1sgQxwFTB05e4WuuFwFoOx/kNMJVSaucteIU1Se/ImZXHamoNj4Fer1ynL1kA== +"@dhis2/analytics@^26.6.8": + version "26.6.8" + resolved "https://registry.yarnpkg.com/@dhis2/analytics/-/analytics-26.6.8.tgz#859f8086198664a9ea14cea149ce7bdf449a19a2" + integrity sha512-9l8001MAx+q8K1Qklui8pfF0rrv3MSLA1dEtM93rBODSsQwRE9pbt5wN44i9+n7nAgc7iItBehAQ1hMJ8j7yHg== dependencies: "@dhis2/d2-ui-rich-text" "^7.4.1" "@dhis2/multi-calendar-dates" "1.0.0"