|
|
@ -4,8 +4,10 @@ import { Props } from 'react-virtualized-auto-sizer'; |
|
|
|
import { EventBusSrv, serializeStateToUrlParam } from '@grafana/data'; |
|
|
|
import { EventBusSrv, serializeStateToUrlParam } from '@grafana/data'; |
|
|
|
import { config } from '@grafana/runtime'; |
|
|
|
import { config } from '@grafana/runtime'; |
|
|
|
import { DataQuery } from '@grafana/schema'; |
|
|
|
import { DataQuery } from '@grafana/schema'; |
|
|
|
|
|
|
|
import store from 'app/core/store'; |
|
|
|
|
|
|
|
|
|
|
|
import { silenceConsoleOutput } from '../../../../test/core/utils/silenceConsoleOutput'; |
|
|
|
import { silenceConsoleOutput } from '../../../../test/core/utils/silenceConsoleOutput'; |
|
|
|
|
|
|
|
import * as localStorage from '../../../core/history/RichHistoryLocalStorage'; |
|
|
|
|
|
|
|
|
|
|
|
import { |
|
|
|
import { |
|
|
|
assertDataSourceFilterVisibility, |
|
|
|
assertDataSourceFilterVisibility, |
|
|
@ -142,6 +144,55 @@ describe('Explore: Query History', () => { |
|
|
|
await assertQueryHistory(['{"expr":"query #2"}', '{"expr":"query #1"}']); |
|
|
|
await assertQueryHistory(['{"expr":"query #2"}', '{"expr":"query #1"}']); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('does not add query if quota exceeded error is reached', 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(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const storeSpy = jest.spyOn(store, 'setObject').mockImplementation(() => { |
|
|
|
|
|
|
|
const error = new Error('QuotaExceededError'); |
|
|
|
|
|
|
|
error.name = 'QuotaExceededError'; |
|
|
|
|
|
|
|
throw error; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await inputQuery('query #2'); |
|
|
|
|
|
|
|
await runQuery(); |
|
|
|
|
|
|
|
await assertQueryHistory(['{"expr":"query #1"}']); |
|
|
|
|
|
|
|
storeSpy.mockRestore(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('does add query if limit exceeded error is reached', 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(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jest.spyOn(localStorage, 'checkLimits').mockImplementationOnce((queries) => { |
|
|
|
|
|
|
|
return { queriesToKeep: queries, limitExceeded: true }; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await inputQuery('query #2'); |
|
|
|
|
|
|
|
await runQuery(); |
|
|
|
|
|
|
|
await assertQueryHistory(['{"expr":"query #2"}', '{"expr":"query #1"}']); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('add comments to query history', async () => { |
|
|
|
it('add comments to query history', async () => { |
|
|
|
const urlParams = { |
|
|
|
const urlParams = { |
|
|
|
left: serializeStateToUrlParam({ |
|
|
|
left: serializeStateToUrlParam({ |
|
|
|