mirror of https://github.com/grafana/grafana
[v11.3.x] DataLinks: Fix onClick functionality (#94907)
DataLinks: Fix onClick functionality (#94815)
* fix: add onclick functionality back to DataLinks in VizPanelFooter
---------
Co-authored-by: Adela Almasan <adela.almasan@grafana.com>
Co-authored-by: Matias Chomicki <matyax@gmail.com>
(cherry picked from commit 5fe5e8a5a6
)
Co-authored-by: Galen Kistler <109082771+gtk-grafana@users.noreply.github.com>
pull/94923/head
parent
1ac972f086
commit
efeb05386b
@ -0,0 +1,35 @@ |
||||
import { render, screen } from '@testing-library/react'; |
||||
import userEvent from '@testing-library/user-event'; |
||||
import { MemoryRouter } from 'react-router-dom-v5-compat'; |
||||
|
||||
import { Field, FieldType, LinkModel } from '@grafana/data'; |
||||
|
||||
import { VizTooltipFooter } from './VizTooltipFooter'; |
||||
|
||||
describe('VizTooltipFooter', () => { |
||||
it('should fire onclick', async () => { |
||||
const onClick = jest.fn(); |
||||
const field: Field = { |
||||
name: '', |
||||
type: FieldType.string, |
||||
values: [], |
||||
config: {}, |
||||
}; |
||||
|
||||
const link: LinkModel<Field> = { |
||||
href: '#', |
||||
onClick, |
||||
title: '', |
||||
origin: field, |
||||
target: undefined, |
||||
}; |
||||
|
||||
render( |
||||
<MemoryRouter> |
||||
<VizTooltipFooter dataLinks={[link]} /> |
||||
</MemoryRouter> |
||||
); |
||||
await userEvent.click(screen.getByRole('link')); |
||||
expect(onClick).toHaveBeenCalled(); |
||||
}); |
||||
}); |
Loading…
Reference in new issue