mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Load Rich History when the container is opened * Store rich history for each pane separately * Do not update currently opened query history when an item is added It's impossible to figure out if the item should be added or not, because filters are applied in the backend. We don't want to replicate that filtering logic in frontend. One way to make it work could be by refreshing both panes. * Test starring and deleting query history items when both panes are open * Remove e2e dependency on ExploreId * Fix unit test * Assert exact queries * Simplify test * Fix e2e tests * Fix toolbar a11y * Reload the history after an item is added * Fix unit test * Remove references to Explore from generic PageToolbar component * Update test name * Fix test assertion * Add issue item to TODO * Improve test assertion * Simplify test setup
33 lines
1.4 KiB
TypeScript
33 lines
1.4 KiB
TypeScript
import { waitFor } from '@testing-library/react';
|
|
import { ExploreId } from '../../../../types';
|
|
import { withinExplore } from './setup';
|
|
|
|
export const assertQueryHistoryExists = (query: string, exploreId: ExploreId = ExploreId.left) => {
|
|
const selector = withinExplore(exploreId);
|
|
|
|
expect(selector.getByText('1 queries')).toBeInTheDocument();
|
|
const queryItem = selector.getByLabelText('Query text');
|
|
expect(queryItem).toHaveTextContent(query);
|
|
};
|
|
|
|
export const assertQueryHistory = async (expectedQueryTexts: string[], exploreId: ExploreId = ExploreId.left) => {
|
|
const selector = withinExplore(exploreId);
|
|
await waitFor(() => {
|
|
expect(selector.getByText(`${expectedQueryTexts.length} queries`)).toBeInTheDocument();
|
|
const queryTexts = selector.getAllByLabelText('Query text');
|
|
expectedQueryTexts.forEach((expectedQueryText, queryIndex) => {
|
|
expect(queryTexts[queryIndex]).toHaveTextContent(expectedQueryText);
|
|
});
|
|
});
|
|
};
|
|
|
|
export const assertQueryHistoryIsStarred = async (expectedStars: boolean[], exploreId: ExploreId = ExploreId.left) => {
|
|
const selector = withinExplore(exploreId);
|
|
const starButtons = selector.getAllByRole('button', { name: /Star query|Unstar query/ });
|
|
await waitFor(() =>
|
|
expectedStars.forEach((starred, queryIndex) => {
|
|
expect(starButtons[queryIndex]).toHaveAccessibleName(starred ? 'Unstar query' : 'Star query');
|
|
})
|
|
);
|
|
};
|