mirror of https://github.com/grafana/grafana
Loki/Explore: Add query type selector (#28817)
* Create query type switcher * Add and update tests * Add handling in datasource * Refactor * Update tests, when checking higlighting, suppy logs * Remove both option as redundant * Add tooltip, remove old comments * Remove unused importts * Remove console.log, update width * Update public/app/plugins/datasource/loki/components/LokiExploreExtraField.tsx Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Update tests * Prettier fixes * Fix test Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>pull/29265/head
parent
9ba8114bd4
commit
4c103663fb
@ -1,32 +1,35 @@ |
||||
import React from 'react'; |
||||
import { shallow } from 'enzyme'; |
||||
import { LokiExploreExtraField, LokiExploreExtraFieldProps } from './LokiExploreExtraField'; |
||||
import { render, screen } from '@testing-library/react'; |
||||
import { LokiExploreExtraFieldProps, LokiExploreExtraField } from './LokiExploreExtraField'; |
||||
|
||||
const setup = (propOverrides?: LokiExploreExtraFieldProps) => { |
||||
const label = 'Loki Explore Extra Field'; |
||||
const value = '123'; |
||||
const type = 'number'; |
||||
const min = 0; |
||||
const onChangeFunc = jest.fn(); |
||||
const queryType = 'range'; |
||||
const lineLimitValue = '1'; |
||||
const onLineLimitChange = jest.fn(); |
||||
const onQueryTypeChange = jest.fn(); |
||||
const onKeyDownFunc = jest.fn(); |
||||
|
||||
const props: any = { |
||||
label, |
||||
value, |
||||
type, |
||||
min, |
||||
onChangeFunc, |
||||
queryType, |
||||
lineLimitValue, |
||||
onLineLimitChange, |
||||
onQueryTypeChange, |
||||
onKeyDownFunc, |
||||
}; |
||||
|
||||
Object.assign(props, propOverrides); |
||||
|
||||
return shallow(<LokiExploreExtraField {...props} />); |
||||
return render(<LokiExploreExtraField {...props} />); |
||||
}; |
||||
|
||||
describe('LokiExploreExtraField', () => { |
||||
it('should render component', () => { |
||||
const wrapper = setup(); |
||||
expect(wrapper).toMatchSnapshot(); |
||||
it('should render step field', () => { |
||||
setup(); |
||||
expect(screen.getByTestId('lineLimitField')).toBeInTheDocument(); |
||||
}); |
||||
|
||||
it('should render query type field', () => { |
||||
setup(); |
||||
expect(screen.getByTestId('queryTypeField')).toBeInTheDocument(); |
||||
}); |
||||
}); |
||||
|
@ -1,26 +0,0 @@ |
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP |
||||
|
||||
exports[`LokiExploreExtraField should render component 1`] = ` |
||||
<div |
||||
className="gf-form-inline" |
||||
> |
||||
<div |
||||
className="gf-form" |
||||
> |
||||
<Component |
||||
width={5} |
||||
> |
||||
Loki Explore Extra Field |
||||
</Component> |
||||
<input |
||||
className="gf-form-input width-4" |
||||
min={0} |
||||
onChange={[MockFunction]} |
||||
onKeyDown={[MockFunction]} |
||||
placeholder="auto" |
||||
type="number" |
||||
value="123" |
||||
/> |
||||
</div> |
||||
</div> |
||||
`; |
Loading…
Reference in new issue