mirror of
https://github.com/grafana/grafana.git
synced 2025-09-27 19:34:53 +08:00

* Elasticsearch: use proper semver strings to identify ES version * Update BE & tests * refactor BE tests * refactor isValidOption check * update test * Update pkg/tsdb/elasticsearch/client/client.go Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com> * Update pkg/tsdb/elasticsearch/client/search_request_test.go Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com> * Remove leftover FIXME comment * Add new test cases for new version format * Docs: add documentation about version dropdown * Update docs/sources/datasources/elasticsearch.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update docs/sources/datasources/elasticsearch.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update docs/sources/datasources/elasticsearch.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update provisioning documentation Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com> Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
import React from 'react';
|
|
import { mount, shallow } from 'enzyme';
|
|
import { ConfigEditor } from './ConfigEditor';
|
|
import { DataSourceHttpSettings } from '@grafana/ui';
|
|
import { ElasticDetails } from './ElasticDetails';
|
|
import { LogsConfig } from './LogsConfig';
|
|
import { createDefaultConfigOptions } from './mocks';
|
|
|
|
describe('ConfigEditor', () => {
|
|
it('should render without error', () => {
|
|
mount(<ConfigEditor onOptionsChange={() => {}} options={createDefaultConfigOptions()} />);
|
|
});
|
|
|
|
it('should render all parts of the config', () => {
|
|
const wrapper = shallow(<ConfigEditor onOptionsChange={() => {}} options={createDefaultConfigOptions()} />);
|
|
expect(wrapper.find(DataSourceHttpSettings).length).toBe(1);
|
|
expect(wrapper.find(ElasticDetails).length).toBe(1);
|
|
expect(wrapper.find(LogsConfig).length).toBe(1);
|
|
});
|
|
|
|
it('should set defaults', () => {
|
|
const options = createDefaultConfigOptions();
|
|
// @ts-ignore
|
|
delete options.jsonData.esVersion;
|
|
// @ts-ignore
|
|
delete options.jsonData.timeField;
|
|
delete options.jsonData.maxConcurrentShardRequests;
|
|
|
|
expect.assertions(3);
|
|
|
|
mount(
|
|
<ConfigEditor
|
|
onOptionsChange={(options) => {
|
|
expect(options.jsonData.esVersion).toBe('5.0.0');
|
|
expect(options.jsonData.timeField).toBe('@timestamp');
|
|
expect(options.jsonData.maxConcurrentShardRequests).toBe(256);
|
|
}}
|
|
options={options}
|
|
/>
|
|
);
|
|
});
|
|
|
|
it('should not apply default if values are set', () => {
|
|
const onChange = jest.fn();
|
|
|
|
mount(<ConfigEditor onOptionsChange={onChange} options={createDefaultConfigOptions()} />);
|
|
|
|
expect(onChange).toHaveBeenCalledTimes(0);
|
|
});
|
|
});
|