grafana/public/app/features/explore/SecondaryActions.test.tsx
Piotr Jamróz 7d2e9aa979
Elasticsearch: Enable full range log volume histogram (#41202)
* Rename "Logs volume" labels to "Log volume"

Code references are kept intact as there's a lot of them, it could be renamed in a separate PR just with renaming

* Add log level docs

* Remove feature flag to enable log volume by default

* Update error message

* Update docs

* Fix unit test

* Fix unit test

Queries are now run automatically

* Add extra param for Loki API

* Remove "Load volume" button

* Update documentation about log volume

* Move comment

* Make reload button more accessible

* Update docs/sources/explore/logs-integration.md

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

* Hide full range log volume for Loki behind the feature toggle

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
2021-11-10 11:20:30 +01:00

70 lines
2.3 KiB
TypeScript

import React from 'react';
import { noop } from 'lodash';
import { shallow } from 'enzyme';
import { SecondaryActions } from './SecondaryActions';
const addQueryRowButtonSelector = '[aria-label="Add row button"]';
const richHistoryButtonSelector = '[aria-label="Rich history button"]';
const queryInspectorButtonSelector = '[aria-label="Query inspector button"]';
describe('SecondaryActions', () => {
it('should render component two buttons', () => {
const wrapper = shallow(
<SecondaryActions
onClickAddQueryRowButton={noop}
onClickRichHistoryButton={noop}
onClickQueryInspectorButton={noop}
/>
);
expect(wrapper.find(addQueryRowButtonSelector)).toHaveLength(1);
expect(wrapper.find(richHistoryButtonSelector)).toHaveLength(1);
});
it('should not render add row button if addQueryRowButtonHidden=true', () => {
const wrapper = shallow(
<SecondaryActions
addQueryRowButtonHidden={true}
onClickAddQueryRowButton={noop}
onClickRichHistoryButton={noop}
onClickQueryInspectorButton={noop}
/>
);
expect(wrapper.find(addQueryRowButtonSelector)).toHaveLength(0);
expect(wrapper.find(richHistoryButtonSelector)).toHaveLength(1);
});
it('should disable add row button if addQueryRowButtonDisabled=true', () => {
const wrapper = shallow(
<SecondaryActions
addQueryRowButtonDisabled={true}
onClickAddQueryRowButton={noop}
onClickRichHistoryButton={noop}
onClickQueryInspectorButton={noop}
/>
);
expect(wrapper.find(addQueryRowButtonSelector).props().disabled).toBe(true);
});
it('should map click handlers correctly', () => {
const onClickAddRow = jest.fn();
const onClickHistory = jest.fn();
const onClickQueryInspector = jest.fn();
const wrapper = shallow(
<SecondaryActions
onClickAddQueryRowButton={onClickAddRow}
onClickRichHistoryButton={onClickHistory}
onClickQueryInspectorButton={onClickQueryInspector}
/>
);
wrapper.find(addQueryRowButtonSelector).simulate('click');
expect(onClickAddRow).toBeCalled();
wrapper.find(richHistoryButtonSelector).simulate('click');
expect(onClickHistory).toBeCalled();
wrapper.find(queryInspectorButtonSelector).simulate('click');
expect(onClickQueryInspector).toBeCalled();
});
});