-
Notifications
You must be signed in to change notification settings - Fork 216
PMM-14901: RTA details arrows respect filters #5397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mattiasimonato
wants to merge
16
commits into
v3
Choose a base branch
from
PMM-14901-rta-details-arrows-respect-filters
base: v3
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
3190469
fix: RTA details pane arrows follow filtered table rows
mattiasimonato 808f58e
test: add RTA overview filtered navigation tests
mattiasimonato d22e2e7
Merge branch 'v3' into PMM-14901-rta-details-arrows-respect-filters
mattiasimonato c4b5954
fix: lint warnings
mattiasimonato 64567bb
fix: sync RTA details navigation with table sort order
mattiasimonato f914530
fix: disable RTA details navigation when selection is not navigable
mattiasimonato 5aa136a
fix: keep RTA overview column-only filtering
mattiasimonato 4ed774d
test: wait for RTA navigation assertions after pane updates
mattiasimonato 3de3b97
Merge branch 'v3' into PMM-14901-rta-details-arrows-respect-filters
mattiasimonato f84b62c
fix: prevent RTA overview navigable-sync render loop
mattiasimonato 2fcd4ad
fix: remove unused imports in OverviewTable utils
mattiasimonato 5f5035b
fix: type resolveTableStateUpdate for tsc build
mattiasimonato 8549392
refactor: use plain MRT setters for RTA overview table
mattiasimonato 84560c0
Merge branch 'v3' into PMM-14901-rta-details-arrows-respect-filters
mattiasimonato a280c7a
fix: always sync RTA navigable queries on table updates
mattiasimonato dc823c7
Merge branch 'v3' into PMM-14901-rta-details-arrows-respect-filters
mattiasimonato File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
197 changes: 197 additions & 0 deletions
197
ui/apps/pmm/src/pages/rta/overview/RealtimeOverview.navigation.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,197 @@ | ||
| /** | ||
| * Details-pane prev/next must follow the table's filtered rows (navigableQueries), | ||
| * not the full list returned by the API. | ||
| * | ||
| * In the app, OverviewTable syncs navigableQueries from Material React Table after | ||
| * filters are applied. RealtimeOverview uses that list for arrow navigation. | ||
| * | ||
| * We mock OverviewTable here so we can fix navigableQueries (query-1, query-2) while | ||
| * the API still returns an extra query (query-3) that would be next if we used the | ||
| * unfiltered array. RealtimeOverview.test.tsx keeps the real table for other behavior. | ||
| */ | ||
| import { fireEvent, render, screen, waitFor } from '@testing-library/react'; | ||
| import { FC, useEffect } from 'react'; | ||
| import { MemoryRouter, Route, Routes } from 'react-router-dom'; | ||
| import { wrapWithQueryProvider } from 'utils/testUtils'; | ||
| import { TEST_MONGO_DB_QUERY_DATA, TEST_REAL_TIME_SESSION } from 'utils/testStubs'; | ||
| import { QueryData } from 'types/rta.types'; | ||
| import RealtimeOverview from './RealtimeOverview'; | ||
|
|
||
| const queryOne: QueryData = { | ||
| ...TEST_MONGO_DB_QUERY_DATA, | ||
| queryId: 'query-1', | ||
| }; | ||
|
|
||
| const queryTwo: QueryData = { | ||
| ...TEST_MONGO_DB_QUERY_DATA, | ||
| queryId: 'query-2', | ||
| }; | ||
|
|
||
| const queryFilteredOut: QueryData = { | ||
| ...TEST_MONGO_DB_QUERY_DATA, | ||
| queryId: 'query-3', | ||
| }; | ||
|
|
||
| const navigableQueries = [queryOne, queryTwo]; | ||
|
|
||
| const { searchQueries, getRunningSessions, mockNavigableQueries } = vi.hoisted(() => { | ||
| let navigable: QueryData[] = []; | ||
|
|
||
| return { | ||
| searchQueries: vi.fn(), | ||
| getRunningSessions: vi.fn(), | ||
| mockNavigableQueries: { | ||
| get: () => navigable, | ||
| set: (queries: QueryData[]) => { | ||
| navigable = queries; | ||
| }, | ||
| }, | ||
| }; | ||
| }); | ||
|
|
||
| vi.mock('api/rta', () => ({ | ||
| searchQueries, | ||
| getRunningSessions, | ||
| })); | ||
|
|
||
| vi.mock('./table/OverviewTable', () => { | ||
| const MockOverviewTable: FC<{ | ||
| onQuerySelected: (query: QueryData) => void; | ||
| onNavigableQueriesChange: (queries: QueryData[]) => void; | ||
| }> = ({ onQuerySelected, onNavigableQueriesChange }) => { | ||
| useEffect(() => { | ||
| onNavigableQueriesChange(mockNavigableQueries.get()); | ||
| }, [onNavigableQueriesChange]); | ||
|
|
||
| return ( | ||
| <> | ||
| <button | ||
| type="button" | ||
| data-testid="mock-select-first-query" | ||
| onClick={() => onQuerySelected(queryOne)} | ||
| > | ||
| Select first query | ||
| </button> | ||
| <button | ||
| type="button" | ||
| data-testid="mock-drop-selected-from-navigable" | ||
| onClick={() => { | ||
| mockNavigableQueries.set([queryTwo]); | ||
| onNavigableQueriesChange(mockNavigableQueries.get()); | ||
| }} | ||
| > | ||
| Drop selected from navigable | ||
| </button> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| return { default: MockOverviewTable }; | ||
| }); | ||
|
|
||
| const renderComponent = () => | ||
| render( | ||
| wrapWithQueryProvider( | ||
| <MemoryRouter | ||
| initialEntries={[ | ||
| `/rta/overview?serviceIds=${TEST_REAL_TIME_SESSION.serviceId}`, | ||
| ]} | ||
| > | ||
| <Routes> | ||
| <Route path="/rta/overview" element={<RealtimeOverview />} /> | ||
| </Routes> | ||
| </MemoryRouter> | ||
| ) | ||
| ); | ||
|
|
||
| const openDetailsPaneOnFirstQuery = async () => { | ||
| await waitFor(() => | ||
| expect(screen.getByTestId('mock-select-first-query')).toBeInTheDocument() | ||
| ); | ||
| fireEvent.click(screen.getByTestId('mock-select-first-query')); | ||
| await waitFor(() => | ||
| expect(screen.getByTestId('query-details-pane')).toHaveAttribute( | ||
| 'aria-hidden', | ||
| 'false' | ||
| ) | ||
| ); | ||
| }; | ||
|
|
||
| const getOperationId = () => screen.getByTestId('operation-id-value'); | ||
|
|
||
| describe('RealtimeOverview details pane navigation', () => { | ||
| beforeEach(() => { | ||
| vi.clearAllMocks(); | ||
| mockNavigableQueries.set(navigableQueries); | ||
|
|
||
| searchQueries.mockResolvedValue({ | ||
| queries: [...navigableQueries, queryFilteredOut], | ||
| }); | ||
|
|
||
| getRunningSessions.mockResolvedValue([TEST_REAL_TIME_SESSION]); | ||
| }); | ||
|
|
||
| it('navigates to the next visible query, not the next API query', async () => { | ||
| renderComponent(); | ||
| await openDetailsPaneOnFirstQuery(); | ||
|
|
||
| expect(getOperationId()).toHaveTextContent('query-1'); | ||
|
|
||
| fireEvent.click(screen.getByTestId('details-pane-next-button')); | ||
|
|
||
| await waitFor(() => { | ||
| expect(getOperationId()).toHaveTextContent('query-2'); | ||
| }); | ||
| expect(getOperationId()).not.toHaveTextContent('query-3'); | ||
| }); | ||
|
|
||
| it('navigates to the previous visible query', async () => { | ||
| renderComponent(); | ||
| await openDetailsPaneOnFirstQuery(); | ||
|
|
||
| fireEvent.click(screen.getByTestId('details-pane-next-button')); | ||
| await waitFor(() => { | ||
| expect(getOperationId()).toHaveTextContent('query-2'); | ||
| }); | ||
|
|
||
| fireEvent.click(screen.getByTestId('details-pane-prev-button')); | ||
| await waitFor(() => { | ||
| expect(getOperationId()).toHaveTextContent('query-1'); | ||
| }); | ||
| }); | ||
|
|
||
| it('disables prev on the first visible query and next on the last', async () => { | ||
| renderComponent(); | ||
| await openDetailsPaneOnFirstQuery(); | ||
|
|
||
| expect(screen.getByTestId('details-pane-prev-button')).toBeDisabled(); | ||
| expect(screen.getByTestId('details-pane-next-button')).not.toBeDisabled(); | ||
|
|
||
| fireEvent.click(screen.getByTestId('details-pane-next-button')); | ||
|
|
||
| await waitFor(() => { | ||
| expect(screen.getByTestId('details-pane-prev-button')).not.toBeDisabled(); | ||
| expect(screen.getByTestId('details-pane-next-button')).toBeDisabled(); | ||
| }); | ||
| }); | ||
|
|
||
| it('disables navigation when the selected query is not in navigableQueries', async () => { | ||
| renderComponent(); | ||
| await openDetailsPaneOnFirstQuery(); | ||
|
|
||
| expect(getOperationId()).toHaveTextContent('query-1'); | ||
|
|
||
| fireEvent.click(screen.getByTestId('mock-drop-selected-from-navigable')); | ||
|
|
||
| await waitFor(() => { | ||
| expect(screen.getByTestId('details-pane-prev-button')).toBeDisabled(); | ||
| expect(screen.getByTestId('details-pane-next-button')).toBeDisabled(); | ||
| }); | ||
|
|
||
| fireEvent.click(screen.getByTestId('details-pane-next-button')); | ||
|
|
||
| await waitFor(() => { | ||
| expect(getOperationId()).toHaveTextContent('query-1'); | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.