* Special case mixed datasources... :/ * Revert "Special case mixed datasources... :/" This reverts commitdd0e3ea4a8. * Ensure testdata persists datasource when switching scenario * Add a unit test to prevent regressions * kick drone (cherry picked from commitd4d306d825) Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
This commit is contained in:
co-authored by
Ashley Harrison
parent
67a3609cb8
commit
a23bacc3e2
@@ -82,4 +82,21 @@ describe('Test Datasource Query Editor', () => {
|
||||
expect(screen.getByLabelText('Spread')).toHaveValue(3.5);
|
||||
expect(screen.getByLabelText('Bands')).toHaveValue(1);
|
||||
});
|
||||
|
||||
it('persists the datasource from the query when switching scenario', async () => {
|
||||
const mockDatasource = {
|
||||
type: 'test',
|
||||
uid: 'foo',
|
||||
};
|
||||
setup({
|
||||
query: {
|
||||
...defaultQuery,
|
||||
datasource: mockDatasource,
|
||||
},
|
||||
});
|
||||
let select = (await screen.findByText('Scenario')).nextSibling!.firstChild!;
|
||||
await fireEvent.keyDown(select, { keyCode: 40 });
|
||||
await userEvent.click(screen.getByText('Grafana API'));
|
||||
expect(mockOnChange).toHaveBeenCalledWith(expect.objectContaining({ datasource: mockDatasource }));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -81,6 +81,7 @@ export const QueryEditor = ({ query, datasource, onChange, onRunQuery }: Props)
|
||||
scenarioId: item.value!,
|
||||
refId: query.refId,
|
||||
alias: query.alias,
|
||||
datasource: query.datasource,
|
||||
};
|
||||
|
||||
if (scenario.stringInput) {
|
||||
|
||||
Reference in New Issue
Block a user