Skip to content

Commit

Permalink
fix: do not disable Edit layer in the more menu
Browse files Browse the repository at this point in the history
  • Loading branch information
jenniferarnesen committed Nov 11, 2024
1 parent e792303 commit 43e39b6
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/components/layers/toolbar/LayerToolbarMoreMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ const LayerToolbarMoreMenu = ({
setIsOpen(false)
onEdit()
}}
disabled={hasError}
/>
)}
{onRemove && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<Provider store={mockStore(store)}>
<LayerToolbarMoreMenu
layer={layer}
toggleDataTable={jest.fn()}
onRemove={jest.fn()}
onEdit={jest.fn()}
downloadData={jest.fn()}
hasError={true}
/>
</Provider>
)

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()
})
})
})
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==
Expand Down

0 comments on commit 43e39b6

Please sign in to comment.