diff --git a/src/components/layers/toolbar/LayerToolbarMoreMenu.js b/src/components/layers/toolbar/LayerToolbarMoreMenu.js index 8f5ca7489..ef35aa5b8 100644 --- a/src/components/layers/toolbar/LayerToolbarMoreMenu.js +++ b/src/components/layers/toolbar/LayerToolbarMoreMenu.js @@ -115,7 +115,6 @@ const LayerToolbarMoreMenu = ({ setIsOpen(false) onEdit() }} - disabled={hasError} /> )} {onRemove && ( diff --git a/src/components/layers/toolbar/__tests__/LayerToolbarMoreMenu.spec.js b/src/components/layers/toolbar/__tests__/LayerToolbarMoreMenu.spec.js index 15a1950f0..7e9377b22 100644 --- a/src/components/layers/toolbar/__tests__/LayerToolbarMoreMenu.spec.js +++ b/src/components/layers/toolbar/__tests__/LayerToolbarMoreMenu.spec.js @@ -221,4 +221,67 @@ describe('LayerToolbarMoreMenu', () => { expect(screen.queryByText('Open as chart')).toBeNull() }) }) + + test('renders disabled menu items if there was an error', async () => { + const store = { + aggregations: {}, + } + + const layer = { + id: 'rainbowdash', + data: 'hasdata', + } + + render( + + + + ) + + fireEvent.click(screen.getByLabelText('Toggle layer menu')) + + await waitFor(() => { + expect(screen.queryByText('Show data table')).toBeTruthy() + expect( + screen + .queryByText('Show data table') + .closest('li') + .classList.contains('disabled') + ).toBe(true) + + expect(screen.queryByText('Download data')).toBeTruthy() + expect( + screen + .queryByText('Download data') + .closest('li') + .classList.contains('disabled') + ).toBe(true) + expect(screen.queryByText('Edit layer')).toBeTruthy() + expect( + screen + .queryByText('Edit layer') + .closest('li') + .classList.contains('disabled') + ).toBe(false) + + expect(screen.queryByText('Remove layer')).toBeTruthy() + expect( + screen + .queryByText('Remove layer') + .closest('li') + .classList.contains('disabled') + ).toBe(false) + // confirm the divider is present (1 more list item) + expect(screen.getByRole('menu').children.length).toEqual(5) + + expect(screen.queryByText('Open as chart')).toBeNull() + }) + }) }) diff --git a/yarn.lock b/yarn.lock index f3b415814..47963db33 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2323,7 +2323,7 @@ resolved "https://registry.yarnpkg.com/@dhis2/ui-icons/-/ui-icons-9.13.0.tgz#321ffcaadade8e4b29600fe5208e5f07ba1be26b" integrity sha512-elFOMwpL4St5cAjdUy8PqSzaSJcfhdlZG8aARvvaAwtA42s2QZp/zXaztOjshjN8iQBFZMqH93XqQh8Dmqb0mA== -"@dhis2/ui@9.13.0", "@dhis2/ui@^9.13.0", "@dhis2/ui@^9.8.9": +"@dhis2/ui@^9.13.0", "@dhis2/ui@^9.8.9": version "9.13.0" resolved "https://registry.yarnpkg.com/@dhis2/ui/-/ui-9.13.0.tgz#191a3e14f3a4874f02e44e94e53cbe1694c69de3" integrity sha512-VuqW+jF/tf99ZjnyaFdRmPj1BBeFs22XBEqGFOiClPSTT2d6xIcX7VPY7+vf99WnadijQ4/T2238FhtjIVidXw==