mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: Test deleting comments in query history (#70934)
* Working test
This commit is contained in:
parent
276c63a656
commit
4b3050e02e
@ -21,6 +21,13 @@ export const assertQueryHistory = async (expectedQueryTexts: string[], exploreId
|
||||
});
|
||||
};
|
||||
|
||||
export const assertQueryHistoryIsEmpty = async (exploreId = 'left') => {
|
||||
const selector = withinExplore(exploreId);
|
||||
const queryTexts = selector.queryAllByLabelText('Query text');
|
||||
|
||||
expect(await queryTexts).toHaveLength(0);
|
||||
};
|
||||
|
||||
export const assertQueryHistoryComment = async (expectedQueryComments: string[], exploreId = 'left') => {
|
||||
const selector = withinExplore(exploreId);
|
||||
await waitFor(() => {
|
||||
|
@ -15,6 +15,7 @@ import {
|
||||
assertQueryHistoryExists,
|
||||
assertQueryHistoryIsStarred,
|
||||
assertQueryHistoryTabIsSelected,
|
||||
assertQueryHistoryIsEmpty,
|
||||
} from './helper/assert';
|
||||
import {
|
||||
commentQueryHistory,
|
||||
@ -211,6 +212,31 @@ describe('Explore: Query History', () => {
|
||||
await assertQueryHistoryComment(['test comment'], 'left');
|
||||
});
|
||||
|
||||
it('removes the query item from the history panel when user deletes a regular query', async () => {
|
||||
const urlParams = {
|
||||
left: serializeStateToUrlParam({
|
||||
datasource: 'loki',
|
||||
queries: [{ refId: 'A', expr: 'query #1' }],
|
||||
range: { from: 'now-1h', to: 'now' },
|
||||
}),
|
||||
};
|
||||
|
||||
const { datasources } = setupExplore({ urlParams });
|
||||
jest.mocked(datasources.loki.query).mockReturnValueOnce(makeLogsQueryResponse());
|
||||
|
||||
await waitForExplore();
|
||||
await openQueryHistory();
|
||||
|
||||
// queries in history
|
||||
await assertQueryHistory(['{"expr":"query #1"}'], 'left');
|
||||
|
||||
// delete query
|
||||
await deleteQueryHistory(0, 'left');
|
||||
|
||||
// there was only one query in history so assert that query history is empty
|
||||
await assertQueryHistoryIsEmpty('left');
|
||||
});
|
||||
|
||||
it('updates query history settings', async () => {
|
||||
// open settings page
|
||||
setupExplore();
|
||||
|
Loading…
Reference in New Issue
Block a user