Explore: Do not assert order of query history items when initializing from URL (#76806)

Assert initial state of the query history without requiring correct order.
This commit is contained in:
Piotr Jamróz
2023-10-19 19:31:06 +02:00
committed by GitHub
parent 4073e50da9
commit 8f6a3c18c5
2 changed files with 14 additions and 2 deletions
@@ -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(() => {
@@ -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 () => {