diff --git a/public/app/features/explore/spec/helper/assert.ts b/public/app/features/explore/spec/helper/assert.ts index 1a2cb4acf71..d320cffcb8a 100644 --- a/public/app/features/explore/spec/helper/assert.ts +++ b/public/app/features/explore/spec/helper/assert.ts @@ -10,6 +10,15 @@ export const assertQueryHistoryExists = async (query: string, exploreId = 'left' expect(queryItem).toHaveTextContent(query); }; +export const assertQueryHistoryContains = async (query: string, exploreId = 'left') => { + const selector = withinExplore(exploreId); + + await waitFor(() => { + const containsQuery = selector.getAllByLabelText('Query text').map((e) => (e.textContent || '').includes(query)); + expect(containsQuery).toContain(true); + }); +}; + export const assertQueryHistory = async (expectedQueryTexts: string[], exploreId = 'left') => { const selector = withinExplore(exploreId); await waitFor(() => { diff --git a/public/app/features/explore/spec/queryHistory.test.tsx b/public/app/features/explore/spec/queryHistory.test.tsx index 5c7c93abb13..6db3d87335e 100644 --- a/public/app/features/explore/spec/queryHistory.test.tsx +++ b/public/app/features/explore/spec/queryHistory.test.tsx @@ -10,6 +10,7 @@ import { assertLoadMoreQueryHistoryNotVisible, assertQueryHistory, assertQueryHistoryComment, + assertQueryHistoryContains, assertQueryHistoryElementsShown, assertQueryHistoryExists, assertQueryHistoryIsEmpty, @@ -163,8 +164,10 @@ describe('Explore: Query History', () => { }); it('initial state is in sync', async () => { - await assertQueryHistory(['{"expr":"query #2"}', '{"expr":"query #1"}'], 'left'); - await assertQueryHistory(['{"expr":"query #2"}', '{"expr":"query #1"}'], 'right'); + await assertQueryHistoryContains('{"expr":"query #1"}', 'left'); + await assertQueryHistoryContains('{"expr":"query #2"}', 'left'); + await assertQueryHistoryContains('{"expr":"query #1"}', 'right'); + await assertQueryHistoryContains('{"expr":"query #2"}', 'right'); }); it('starred queries are synced', async () => {