- DYNAMIC_ORG_UNITS.includes(item.id)
- ),
hidden: hideLevelSelect && hideGroupSelect,
})}
>
diff --git a/src/components/OrgUnitDimension/__tests__/OrgUnitDimension.spec.js b/src/components/OrgUnitDimension/__tests__/OrgUnitDimension.spec.js
new file mode 100644
index 000000000..9f85b035b
--- /dev/null
+++ b/src/components/OrgUnitDimension/__tests__/OrgUnitDimension.spec.js
@@ -0,0 +1,59 @@
+import { shallow } from 'enzyme'
+import React from 'react'
+import OrgUnitDimension from '../OrgUnitDimension.js'
+
+describe('The OrgUnitDimension component', () => {
+ let props
+ let shallowOrgUnitDimension
+
+ const getWrapper = () => {
+ if (!shallowOrgUnitDimension) {
+ shallowOrgUnitDimension = shallow(
)
+ }
+ return shallowOrgUnitDimension
+ }
+
+ beforeEach(() => {
+ props = {
+ roots: [],
+ selected: [],
+ onSelect: jest.fn(),
+ hideGroupSelect: false,
+ hideLevelSelect: false,
+ hideUserOrgUnits: false,
+ warning: '',
+ }
+ shallowOrgUnitDimension = undefined
+ })
+
+ it('matches the snapshot', () => {
+ const wrapper = getWrapper()
+ expect(wrapper).toMatchSnapshot()
+ })
+
+ it('calls onSelect when an organisation unit is selected', () => {
+ const wrapper = getWrapper()
+ const orgUnitTree = wrapper.find('OrganisationUnitTree')
+ const testOrgUnit = {
+ id: 'testId',
+ path: '/testPath',
+ displayName: 'Test Org Unit',
+ checked: true,
+ }
+ orgUnitTree.props().onChange(testOrgUnit)
+ expect(props.onSelect).toHaveBeenCalledWith({
+ dimensionId: 'ou',
+ items: [{ id: 'testId', path: '/testPath', name: 'Test Org Unit' }],
+ })
+ })
+
+ it('calls onSelect with an empty array when selection is cleared', () => {
+ const wrapper = getWrapper()
+ const deselectButton = wrapper.find('Button[onClick]')
+ deselectButton.simulate('click')
+ expect(props.onSelect).toHaveBeenCalledWith({
+ dimensionId: 'ou',
+ items: [],
+ })
+ })
+})
diff --git a/src/components/OrgUnitDimension/__tests__/__snapshots__/OrgUnitDimension.spec.js.snap b/src/components/OrgUnitDimension/__tests__/__snapshots__/OrgUnitDimension.spec.js.snap
new file mode 100644
index 000000000..1faa60b95
--- /dev/null
+++ b/src/components/OrgUnitDimension/__tests__/__snapshots__/OrgUnitDimension.spec.js.snap
@@ -0,0 +1,94 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`The OrgUnitDimension component matches the snapshot 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Nothing selected
+
+
+
+
+
+
+
+`;
diff --git a/src/components/PivotTable/PivotTableTitleRows.js b/src/components/PivotTable/PivotTableTitleRows.js
index 8a3439c9d..b29439261 100644
--- a/src/components/PivotTable/PivotTableTitleRows.js
+++ b/src/components/PivotTable/PivotTableTitleRows.js
@@ -6,6 +6,7 @@ import { PivotTableTitleRow } from './PivotTableTitleRow.js'
export const PivotTableTitleRows = ({ clippingResult, width }) => {
const engine = usePivotTableEngine()
+
return (
<>
{engine.options.title ? (
diff --git a/src/modules/__tests__/getOuLevelAndGroupText.spec.js b/src/modules/__tests__/getOuLevelAndGroupText.spec.js
index a57a07539..21cb7319b 100644
--- a/src/modules/__tests__/getOuLevelAndGroupText.spec.js
+++ b/src/modules/__tests__/getOuLevelAndGroupText.spec.js
@@ -61,4 +61,15 @@ describe('getOuLevelAndGroupText', () => {
'Fruit and Veggies groups - Second floor levels'
)
})
+
+ it('grabs name for user orgunits from items when not present in metaData', () => {
+ filter.items = [
+ { id: 'USER_ORGUNIT', name: 'User organisation unit' },
+ { id: 'LEVEL-2nd-floor' },
+ ]
+
+ expect(getOuLevelAndGroupText(filter, metaData)).toEqual(
+ 'Second floor levels in User organisation unit'
+ )
+ })
})
diff --git a/src/modules/getOuLevelAndGroupText.js b/src/modules/getOuLevelAndGroupText.js
index f92e612c2..a7622e28f 100644
--- a/src/modules/getOuLevelAndGroupText.js
+++ b/src/modules/getOuLevelAndGroupText.js
@@ -28,7 +28,9 @@ export const getOuLevelAndGroupText = (filter, metaData) => {
const getLevelAndGroupText = (items, metaData, isLevel) => {
const getNameFromMetadata = (id) =>
- metaData.items[id] ? metaData.items[id].name : id
+ metaData.items[id]
+ ? metaData.items[id].name
+ : items.find((item) => item.id === id)?.name || id
const dynamicOuItems = items.filter((item) =>
isLevel