Fix create a dashboard from Explorer and edit panel flow (#54551)

This commit is contained in:
Beto Muniz 2022-09-01 10:18:57 -03:00 committed by GitHub
parent 7e2238cf6f
commit 29ff97a4b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -26,6 +26,22 @@ describe('PromQueryBuilderOptions', () => {
}); });
}); });
it('Can set query type to "Both" on render for PanelEditor', async () => {
setup({ instant: true, range: true });
screen.getByTitle('Click to edit options').click();
expect(screen.getByLabelText('Both')).toBeChecked();
});
it('Can set query type to "Both" on render for Explorer', async () => {
setup({ instant: true, range: true }, CoreApp.Explore);
screen.getByTitle('Click to edit options').click();
expect(screen.getByLabelText('Both')).toBeChecked();
});
it('Legend format default to Auto', async () => { it('Legend format default to Auto', async () => {
setup(); setup();
expect(screen.getByText('Legend: Auto')).toBeInTheDocument(); expect(screen.getByText('Legend: Auto')).toBeInTheDocument();
@ -85,8 +101,9 @@ describe('PromQueryBuilderOptions', () => {
}); });
}); });
function setup(queryOverrides: Partial<PromQuery> = {}) { function setup(queryOverrides: Partial<PromQuery> = {}, app: CoreApp = CoreApp.PanelEditor) {
const props = { const props = {
app,
query: { query: {
...getQueryWithDefaults({ refId: 'A' } as PromQuery, CoreApp.PanelEditor), ...getQueryWithDefaults({ refId: 'A' } as PromQuery, CoreApp.PanelEditor),
...queryOverrides, ...queryOverrides,

View File

@ -37,7 +37,7 @@ export const PromQueryBuilderOptions = React.memo<Props>(({ query, app, onChange
onRunQuery(); onRunQuery();
}; };
const queryTypeOptions = getQueryTypeOptions(app === CoreApp.Explore); const queryTypeOptions = getQueryTypeOptions(app === CoreApp.Explore || app === CoreApp.PanelEditor);
const onQueryTypeChange = getQueryTypeChangeHandler(query, onChange); const onQueryTypeChange = getQueryTypeChangeHandler(query, onChange);
const onExemplarChange = (event: SyntheticEvent<HTMLInputElement>) => { const onExemplarChange = (event: SyntheticEvent<HTMLInputElement>) => {