mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* AccessControl: Provide scope to frontend * Covering datasources with accesscontrol metadata * Write benchmark tests for GetResourcesMetadata * Add accesscontrol util and interface * Add the hasPermissionInMetadata function in the frontend access control code * Use IsDisabled rather that performing a feature toggle check Co-authored-by: Karl Persson <kalle.persson@grafana.com>
44 lines
854 B
TypeScript
44 lines
854 B
TypeScript
import React from 'react';
|
|
import { shallow } from 'enzyme';
|
|
import ButtonRow, { Props } from './ButtonRow';
|
|
|
|
jest.mock('app/core/core', () => {
|
|
return {
|
|
contextSrv: {
|
|
hasPermission: () => true,
|
|
},
|
|
};
|
|
});
|
|
|
|
const setup = (propOverrides?: object) => {
|
|
const props: Props = {
|
|
canSave: false,
|
|
canDelete: false,
|
|
onSubmit: jest.fn(),
|
|
onDelete: jest.fn(),
|
|
onTest: jest.fn(),
|
|
exploreUrl: '/explore',
|
|
};
|
|
|
|
Object.assign(props, propOverrides);
|
|
|
|
return shallow(<ButtonRow {...props} />);
|
|
};
|
|
|
|
describe('Render', () => {
|
|
it('should render component', () => {
|
|
const wrapper = setup();
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
});
|
|
|
|
it('should render with buttons enabled', () => {
|
|
const wrapper = setup({
|
|
canSave: true,
|
|
canDelete: true,
|
|
});
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
});
|
|
});
|