-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [TSVB] Supports legends with long values * Add a unit test * Design optimization * Revert changes * Add the missing prop type * Ensure that the limits are respected Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Stratoula Kalafateli <[email protected]>
- Loading branch information
1 parent
613f0d9
commit cfa0f14
Showing
7 changed files
with
184 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...lugins/vis_type_timeseries/public/application/components/panel_config/timeseries.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { shallowWithIntl as shallow } from '@kbn/test/jest'; | ||
|
||
jest.mock('../lib/get_default_query_language', () => ({ | ||
getDefaultQueryLanguage: () => 'kuery', | ||
})); | ||
|
||
import { TimeseriesPanelConfig } from './timeseries'; | ||
import { PanelConfigProps } from './types'; | ||
|
||
describe('TimeseriesPanelConfig', () => { | ||
it('sets the number input to the given value', () => { | ||
const props = ({ | ||
fields: {}, | ||
model: { | ||
max_lines_legend: 2, | ||
}, | ||
onChange: jest.fn(), | ||
} as unknown) as PanelConfigProps; | ||
const wrapper = shallow(<TimeseriesPanelConfig {...props} />); | ||
wrapper.instance().setState({ selectedTab: 'options' }); | ||
expect( | ||
wrapper.find('[data-test-subj="timeSeriesEditorDataMaxLegendLines"]').prop('value') | ||
).toEqual(2); | ||
}); | ||
|
||
it('switches on the truncate legend switch if the prop is set to 1 ', () => { | ||
const props = ({ | ||
fields: {}, | ||
model: { | ||
max_lines_legend: 2, | ||
truncate_legend: 1, | ||
}, | ||
onChange: jest.fn(), | ||
} as unknown) as PanelConfigProps; | ||
const wrapper = shallow(<TimeseriesPanelConfig {...props} />); | ||
wrapper.instance().setState({ selectedTab: 'options' }); | ||
expect( | ||
wrapper.find('[data-test-subj="timeSeriesEditorDataTruncateLegendSwitch"]').prop('value') | ||
).toEqual(1); | ||
}); | ||
|
||
it('switches off the truncate legend switch if the prop is set to 0', () => { | ||
const props = ({ | ||
fields: {}, | ||
model: { | ||
max_lines_legend: 2, | ||
truncate_legend: 0, | ||
}, | ||
onChange: jest.fn(), | ||
} as unknown) as PanelConfigProps; | ||
const wrapper = shallow(<TimeseriesPanelConfig {...props} />); | ||
wrapper.instance().setState({ selectedTab: 'options' }); | ||
expect( | ||
wrapper.find('[data-test-subj="timeSeriesEditorDataTruncateLegendSwitch"]').prop('value') | ||
).toEqual(0); | ||
}); | ||
|
||
it('disables the max lines number input if the truncate legend switch is off', () => { | ||
const props = ({ | ||
fields: {}, | ||
model: { | ||
max_lines_legend: 2, | ||
truncate_legend: 0, | ||
}, | ||
onChange: jest.fn(), | ||
} as unknown) as PanelConfigProps; | ||
const wrapper = shallow(<TimeseriesPanelConfig {...props} />); | ||
wrapper.instance().setState({ selectedTab: 'options' }); | ||
expect( | ||
wrapper.find('[data-test-subj="timeSeriesEditorDataMaxLegendLines"]').prop('disabled') | ||
).toEqual(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters