mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 16:15:42 -06:00
explore: rich-history: add test for old-mode conversion code (#40714)
This commit is contained in:
parent
bb738e35cf
commit
4bf5fa2ad2
@ -1,5 +1,6 @@
|
||||
import {
|
||||
addToRichHistory,
|
||||
getRichHistory,
|
||||
updateStarredInRichHistory,
|
||||
updateCommentInRichHistory,
|
||||
mapNumbertoTimeInSlider,
|
||||
@ -274,4 +275,35 @@ describe('richHistory', () => {
|
||||
expect(heading).toEqual(mock.storedHistory[0].datasourceName);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getRichHistory', () => {
|
||||
afterEach(() => {
|
||||
deleteAllFromRichHistory();
|
||||
expect(store.exists(key)).toBeFalsy();
|
||||
});
|
||||
it('should load from localStorage data in old format', () => {
|
||||
const oldHistoryItem = { ...mock.storedHistory[0], queries: ['test query 1', 'test query 2', 'test query 3'] };
|
||||
store.setObject(key, [oldHistoryItem]);
|
||||
const expectedHistoryItem = {
|
||||
...mock.storedHistory[0],
|
||||
queries: [
|
||||
{
|
||||
expr: 'test query 1',
|
||||
refId: 'A',
|
||||
},
|
||||
{
|
||||
expr: 'test query 2',
|
||||
refId: 'B',
|
||||
},
|
||||
{
|
||||
expr: 'test query 3',
|
||||
refId: 'C',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const result = getRichHistory();
|
||||
expect(result).toStrictEqual([expectedHistoryItem]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -394,7 +394,6 @@ export function filterAndSortQueries(
|
||||
return sortQueries(filteredQueriesToBeSorted, sortOrder);
|
||||
}
|
||||
|
||||
/* These functions are created to migrate string queries (from 6.7 release) to DataQueries. They can be removed after 7.1 release. */
|
||||
function migrateRichHistory(richHistory: RichHistoryQuery[]) {
|
||||
const transformedRichHistory = richHistory.map((query) => {
|
||||
const transformedQueries: DataQuery[] = query.queries.map((q, index) => createDataQuery(query, q, index));
|
||||
|
Loading…
Reference in New Issue
Block a user