Skip to content

Commit

Permalink
fix: keep original item height to avoid PT not showing up (DHIS2-1688…
Browse files Browse the repository at this point in the history
…8) v39 (#2983)

* fix: keep original item height to avoid PT not showing up (DHIS2-16888)

* test: adapt tests to new database

(cherry picked from commit 1156a51)

---------

Co-authored-by: Martin <[email protected]>
  • Loading branch information
edoardo and martinkrulltott authored Feb 29, 2024
1 parent b93c842 commit a16b4b5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
1 change: 1 addition & 0 deletions cypress/elements/dimensionsPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const expectDimensionToNotHaveSelectedStyle = (dimensionId) =>
export const expectRecommendedIconToBeVisible = (dimensionId) =>
cy
.getBySel(getDimensionButtonById(dimensionId))
.scrollIntoView()
.findBySel(recommendedIconEl)
.should('have.length', 1)
.and('be.visible')
2 changes: 1 addition & 1 deletion cypress/integration/dimensions/data.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ describe('Data dimension', () => {
{
name: 'Event data items',
testGroup: { name: 'Information Campaign', itemAmount: 6 },
testItem: { name: 'Diagnosis (ICD-10)' },
testItem: { name: 'E2E TE program 1 First name' },
defaultGroup: { name: 'All programs' },
endpoint: {
hasMultiplePages: true,
Expand Down
26 changes: 12 additions & 14 deletions cypress/integration/dimensions/dynamic.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,25 @@ import {
expectDimensionToHaveItemAmount,
} from '../../elements/layout.js'
import { goToStartPage } from '../../elements/startScreen.js'
import { TEST_DATA_ELEMENTS } from '../../utils/data.js'
import { getRandomArrayItem } from '../../utils/random.js'
import { expectWindowConfigSeriesToHaveLength } from '../../utils/window.js'

const TEST_DATA_ELEMENT_NAME = getRandomArrayItem(TEST_DATA_ELEMENTS).name
const TEST_DYNAMIC_DIMENSION = {
id: 'J5jldMd8OHv',
name: 'Facility type',
itemAmount: 5,
}

describe(`Dynamic dimension - ${TEST_DYNAMIC_DIMENSION.name}`, () => {
it('navigates to the start page and adds a data item', () => {
it('can add and remove items, which persist after saving', () => {
cy.log('navigates to the start page and adds a data item')
goToStartPage()
openDimension(DIMENSION_ID_DATA)
selectDataElements([TEST_DATA_ELEMENT_NAME])
selectDataElements(['ANC 2nd visit'])
clickDimensionModalUpdateButton()
expectVisualizationToBeVisible(VIS_TYPE_COLUMN)
})
const TEST_ITEM = 'Hospital'
it('adds an item manually', () => {

const TEST_ITEM = 'Hospital'
cy.log('adds an item manually')
openDimension(TEST_DYNAMIC_DIMENSION.id)
expectDimensionModalToBeVisible(TEST_DYNAMIC_DIMENSION.id)
expectManualSelectionToBeChecked()
Expand All @@ -49,8 +47,8 @@ describe(`Dynamic dimension - ${TEST_DYNAMIC_DIMENSION.name}`, () => {
expectVisualizationToBeVisible(VIS_TYPE_COLUMN)
expectWindowConfigSeriesToHaveLength(1)
expectDimensionToHaveItemAmount(TEST_DYNAMIC_DIMENSION.id, 1)
})
it('adds all items automatically', () => {

cy.log('adds all items automatically')
openDimension(TEST_DYNAMIC_DIMENSION.id)
expectDimensionModalToBeVisible(TEST_DYNAMIC_DIMENSION.id)
expectManualSelectionToBeChecked()
Expand All @@ -60,8 +58,8 @@ describe(`Dynamic dimension - ${TEST_DYNAMIC_DIMENSION.name}`, () => {
expectVisualizationToBeVisible(VIS_TYPE_COLUMN)
expectWindowConfigSeriesToHaveLength(TEST_DYNAMIC_DIMENSION.itemAmount)
expectDimensionToHaveAllItemsSelected(TEST_DYNAMIC_DIMENSION.id)
})
it('switches back to manual and previous item is presisted', () => {

cy.log('switches back to manual and previous item is persisted')
openDimension(TEST_DYNAMIC_DIMENSION.id)
expectDimensionModalToBeVisible(TEST_DYNAMIC_DIMENSION.id)
expectAutomaticSelectionToBeChecked()
Expand All @@ -72,8 +70,8 @@ describe(`Dynamic dimension - ${TEST_DYNAMIC_DIMENSION.name}`, () => {
expectVisualizationToBeVisible(VIS_TYPE_COLUMN)
expectWindowConfigSeriesToHaveLength(1)
expectDimensionToHaveItemAmount(TEST_DYNAMIC_DIMENSION.id, 1)
})
it('switches back to automatic, saving, the selection is presisted', () => {

cy.log('switches back to automatic, saving, the selection is persisted')
openDimension(TEST_DYNAMIC_DIMENSION.id)
expectDimensionModalToBeVisible(TEST_DYNAMIC_DIMENSION.id)
expectManualSelectionToBeChecked()
Expand Down
9 changes: 7 additions & 2 deletions packages/plugin/src/VisualizationPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@ export const VisualizationPlugin = ({
}
: style

// force height when no value available otherwise the PivotTable container sets 0 as height hiding the table content
// and Highcharts does not render correctly the chart/legend
if (!transformedStyle.height) {
transformedStyle.height = '100%'
}

const getLegendKey = () => {
if (hasLegendSet && forDashboard) {
return (
Expand Down Expand Up @@ -330,8 +336,7 @@ export const VisualizationPlugin = ({
onDrill ? onToggleContextualMenu : undefined
}
id={id}
// force height otherwise the PivotTable container sets 0 as height hiding the table content
style={{ ...transformedStyle, height: '100%' }}
style={transformedStyle}
/>
) : (
<ChartPlugin
Expand Down

0 comments on commit a16b4b5

Please sign in to comment.