Skip to content

Commit

Permalink
Merge branch 'dev' into feat/DHIS2-15657-analytics-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
martinkrulltott authored Oct 26, 2023
2 parents d3835bf + 8666fbb commit 2d630d9
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 31 deletions.
20 changes: 20 additions & 0 deletions cypress/integration/options/legend.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
DIMENSION_ID_PERIOD,
AXIS_ID_COLUMNS,
VIS_TYPE_AREA,
AXIS_ID_ROWS,
} from '@dhis2/analytics'
import {
expectChartTitleToBeVisible,
Expand Down Expand Up @@ -520,6 +521,25 @@ describe('Options - Legend', () => {
expectLegendKeyToBeVisible()
expectLegedKeyItemAmountToBe(1)
})
it('legend is applied when data is in rows', () => {
// swap data and period
openContextMenu(DIMENSION_ID_PERIOD)
clickContextMenuMove(DIMENSION_ID_PERIOD, AXIS_ID_COLUMNS)
openContextMenu(DIMENSION_ID_DATA)
clickContextMenuMove(DIMENSION_ID_DATA, AXIS_ID_ROWS)
clickMenuBarUpdateButton()

// expect legend to still be applied
expectVisualizationToBeVisible(VIS_TYPE_PIVOT_TABLE)
expectLegendKeyToBeVisible()
expectLegedKeyItemAmountToBe(1)
cy.getBySel(valueCellEl).each(($el) => {
cy.wrap($el)
.invoke('attr', 'style')
.should('not.contain', 'background-color')
.and('not.contain', EXPECTED_STANDARD_TEXT_COLOR)
})
})
})
describe('Transferring a legend: Pivot table -> Gauge', () => {
const TEST_ITEM = TEST_ITEMS[0]
Expand Down
46 changes: 31 additions & 15 deletions cypress/integration/save.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
DIMENSION_ID_DATA,
DIMENSION_ID_ORGUNIT,
visTypeDisplayNames,
VIS_TYPE_SCATTER,
} from '@dhis2/analytics'
Expand All @@ -16,10 +17,10 @@ import {
selectIndicators,
selectDataElements,
clickDimensionModalUpdateButton,
deselectOrgUnitTreeItem,
} from '../elements/dimensionModal/index.js'
import { openDimension } from '../elements/dimensionsPanel.js'
import {
//openRandomAOCreatedByOthers,
saveNewAO,
closeFileMenuWithClick,
saveAOAs,
Expand Down Expand Up @@ -184,21 +185,36 @@ describe('saving an AO', () => {
})
})

/*
describe('"save" for a saved AO created by others', () => {
it('navigates to the start page', () => {
describe('"save" a copied AO created by others', () => {
it('works after editing', () => {
const TEST_VIS_BY_OTHERS_NAME = 'ANC: 1-3 dropout rate Yearly'
const TEST_VIS_BY_OTHERS_NAME_UPDATED = `${TEST_VIS_BY_OTHERS_NAME} - updated`

// navigates to the start page and opens an AO created by others
goToStartPage()
})
it('opens a random AO created by others', () => {
openRandomAOCreatedByOthers()
})
it('checks that Save is disabled - WIP', () => {
clickMenuBarFileButton()
expectFileMenuButtonToBeDisabled(FILE_MENU_BUTTON_SAVEAS)
// TODO: This is not always true, as different AOs can have different sharing settings.
// @edoardo will add additional tests here later
closeFileMenuWithClick()
openAOByName(TEST_VIS_BY_OTHERS_NAME)
expectAOTitleToBeValue(TEST_VIS_BY_OTHERS_NAME)

// saves AO using "Save As"
saveAOAs(TEST_VIS_BY_OTHERS_NAME_UPDATED)
expectAOTitleToBeValue(TEST_VIS_BY_OTHERS_NAME_UPDATED)
expectVisualizationToBeVisible()

// edits the AO
openDimension(DIMENSION_ID_ORGUNIT)
deselectOrgUnitTreeItem('Western Area')
clickDimensionModalUpdateButton()

// saves AO using "Save"
saveExistingAO()
expectAOTitleToNotBeDirty()
expectAOTitleToBeValue(TEST_VIS_BY_OTHERS_NAME_UPDATED)
expectVisualizationToBeVisible()

// deletes AO
deleteAO()
expectRouteToBeEmpty()
expectStartScreenToBeVisible()
})
})
*/
})
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"start-server-and-test": "^2.0.0"
},
"dependencies": {
"@dhis2/analytics": "^26.0.21",
"@dhis2/analytics": "^26.1.2",
"@dhis2/app-runtime": "^3.7.0",
"@dhis2/app-runtime-adapter-d2": "^1.1.0",
"@dhis2/app-service-datastore": "^1.0.0-beta.3",
Expand Down
5 changes: 3 additions & 2 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
DIMENSION_ID_PERIOD,
DIMENSION_ID_ORGUNIT,
DIMENSION_ID_ASSIGNED_CATEGORIES,
preparePayloadForSaveAs,
} from '@dhis2/analytics'
import i18n from '@dhis2/d2-i18n'
import { apiPostDataStatistics } from '../api/dataStatistics.js'
Expand Down Expand Up @@ -204,13 +205,13 @@ export const tDoSaveVisualization =

try {
dispatch(fromLoader.acSetPluginLoading(true))
const visualization = getVisualizationFromCurrent(
let visualization = getVisualizationFromCurrent(
sGetCurrent(getState())
)

// remove the id to trigger a POST request and save a new AO
if (copy) {
delete visualization.id
visualization = preparePayloadForSaveAs(visualization)
}

visualization.name =
Expand Down
4 changes: 3 additions & 1 deletion src/components/VisualizationPlugin/VisualizationPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
LEGEND_DISPLAY_STRATEGY_BY_DATA_ITEM,
isLegendSetType,
VIS_TYPE_LINE,
DIMENSION_ID_DATA,
} from '@dhis2/analytics'
import { useDataEngine } from '@dhis2/app-runtime'
import { Button, IconLegend24, Layer } from '@dhis2/ui'
Expand Down Expand Up @@ -260,8 +261,9 @@ export const VisualizationPlugin = ({
case LEGEND_DISPLAY_STRATEGY_BY_DATA_ITEM:
{
if (
fetchResult.visualization.type !== VIS_TYPE_PIVOT_TABLE &&
!fetchResult.visualization.columns.some(
(item) => item.dimension === 'dx'
(item) => item.dimension === DIMENSION_ID_DATA
)
) {
break
Expand Down
17 changes: 5 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2028,10 +2028,10 @@
classnames "^2.3.1"
prop-types "^15.7.2"

"@dhis2/analytics@^26.0.21":
version "26.0.21"
resolved "https://registry.yarnpkg.com/@dhis2/analytics/-/analytics-26.0.21.tgz#72bd6d1a954161411bf5f6cfa24529a039d5ccdd"
integrity sha512-msDRXjqYeareCdUrTrh0jDIzUQe9g7X8kjo9E6KruVjKRKuiZh0IG31enAbnAAefNT+X4i2sL1DLy1DMflWgRg==
"@dhis2/analytics@^26.1.2":
version "26.1.2"
resolved "https://registry.yarnpkg.com/@dhis2/analytics/-/analytics-26.1.2.tgz#cc1a9feae34bea1d0fc61fd6f0fbe03badc5c3a4"
integrity sha512-xBjv/5Ey+PXoPZPtgpYhIgdNtJ3Ce2GtJKy/zU6fFhlm1Vaok5ipaoW6DxmaKdgeQm8VzNVnZdBSjV7+58rAPA==
dependencies:
"@dhis2/d2-ui-rich-text" "^7.4.1"
"@dhis2/multi-calendar-dates" "1.0.0"
Expand Down Expand Up @@ -10916,21 +10916,14 @@ lodash@^4.0.0, lodash@^4.15.0, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.14
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==

[email protected]:
[email protected], log-symbols@^4.0.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.1.0.tgz#3fbdbb95b4683ac9fc785111e792e558d4abd503"
integrity sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==
dependencies:
chalk "^4.1.0"
is-unicode-supported "^0.1.0"

log-symbols@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.0.0.tgz#69b3cc46d20f448eccdb75ea1fa733d9e821c920"
integrity sha512-FN8JBzLx6CzeMrB0tg6pqlGU1wCrXW+ZXGH481kfsBqer0hToTIiHdjH4Mq8xJUbvATujKCvaREGWpGUionraA==
dependencies:
chalk "^4.0.0"

log-update@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/log-update/-/log-update-4.0.0.tgz#589ecd352471f2a1c0c570287543a64dfd20e0a1"
Expand Down

0 comments on commit 2d630d9

Please sign in to comment.