mirror of https://github.com/grafana/grafana
DataLinks: Bring back single click links for Stat, Gauge and BarGauge panel (#31692)
* Bring back clickable Stat, Gauge and BarGauge panels * Demo dashboard * Add DataLinksContextMenu tests * Only use new UI for data links, revert panel links logicpull/30800/head
parent
bbee7da3e0
commit
fdc6f2cc6f
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,77 @@ |
||||
import React from 'react'; |
||||
import { render, screen } from '@testing-library/react'; |
||||
import { DataLinksContextMenu } from './DataLinksContextMenu'; |
||||
import { selectors } from '@grafana/e2e-selectors'; |
||||
|
||||
const fakeAriaLabel = 'fake aria label'; |
||||
describe('DataLinksContextMenu', () => { |
||||
it('renders context menu when there are more than one data links', () => { |
||||
render( |
||||
<DataLinksContextMenu |
||||
links={() => [ |
||||
{ |
||||
href: '/link1', |
||||
title: 'Link1', |
||||
target: '_blank', |
||||
origin: {}, |
||||
}, |
||||
{ |
||||
href: '/link2', |
||||
title: 'Link2', |
||||
target: '_blank', |
||||
origin: {}, |
||||
}, |
||||
]} |
||||
config={{ |
||||
links: [ |
||||
{ |
||||
title: 'Link1', |
||||
url: '/link1', |
||||
}, |
||||
{ |
||||
title: 'Link2', |
||||
url: '/link2', |
||||
}, |
||||
], |
||||
}} |
||||
> |
||||
{() => { |
||||
return <div aria-label="fake aria label" />; |
||||
}} |
||||
</DataLinksContextMenu> |
||||
); |
||||
|
||||
expect(screen.getByLabelText(fakeAriaLabel)).toBeInTheDocument(); |
||||
expect(screen.queryAllByLabelText(selectors.components.DataLinksContextMenu.singleLink)).toHaveLength(0); |
||||
}); |
||||
|
||||
it('renders link when there is a single data link', () => { |
||||
render( |
||||
<DataLinksContextMenu |
||||
links={() => [ |
||||
{ |
||||
href: '/link1', |
||||
title: 'Link1', |
||||
target: '_blank', |
||||
origin: {}, |
||||
}, |
||||
]} |
||||
config={{ |
||||
links: [ |
||||
{ |
||||
title: 'Link1', |
||||
url: '/link1', |
||||
}, |
||||
], |
||||
}} |
||||
> |
||||
{() => { |
||||
return <div aria-label="fake aria label" />; |
||||
}} |
||||
</DataLinksContextMenu> |
||||
); |
||||
|
||||
expect(screen.getByLabelText(fakeAriaLabel)).toBeInTheDocument(); |
||||
expect(screen.getByLabelText(selectors.components.DataLinksContextMenu.singleLink)).toBeInTheDocument(); |
||||
}); |
||||
}); |
Loading…
Reference in new issue