diff --git a/public/app/core/utils/richHistory.test.ts b/public/app/core/utils/richHistory.test.ts index 80e95a3b663..08be5c3ec1b 100644 --- a/public/app/core/utils/richHistory.test.ts +++ b/public/app/core/utils/richHistory.test.ts @@ -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]); + }); + }); }); diff --git a/public/app/core/utils/richHistory.ts b/public/app/core/utils/richHistory.ts index 1ab0dd0604c..b0d995f94bb 100644 --- a/public/app/core/utils/richHistory.ts +++ b/public/app/core/utils/richHistory.ts @@ -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));