Skip to content

Commit

Permalink
fix: fix broken recording tests (filters excluded)
Browse files Browse the repository at this point in the history
  • Loading branch information
tthvo committed Sep 11, 2024
1 parent fa57316 commit 45ceb38
Show file tree
Hide file tree
Showing 10 changed files with 902 additions and 357 deletions.
8 changes: 8 additions & 0 deletions locales/en/public.json
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,15 @@
"TITLE": "Quick starts"
}
},
"RecordingActions": {
"ARIA_LABELS": {
"MENU_TOGGLE": "recording-action-toggle"
}
},
"RecordingFilters": {
"ARIA_LABELS": {
"MENU_TOGGLE": "recording-filters-toggle"
},
"FILTER_CHIP": {
"DURATION_CONTINUOUS": "Continuous",
"DURATION_EXACT": "{{value}}{{unit}}",
Expand Down
9 changes: 5 additions & 4 deletions src/app/Recordings/RecordingActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { Divider, Dropdown, DropdownItem, DropdownList, MenuToggle, MenuToggleEl
import { EllipsisVIcon } from '@patternfly/react-icons';
import { Td } from '@patternfly/react-table';
import * as React from 'react';
import { useTranslation } from 'react-i18next';
import { Observable } from 'rxjs';
import { first } from 'rxjs/operators';

Expand All @@ -39,6 +40,7 @@ export interface RecordingActionsProps {
}

export const RecordingActions: React.FC<RecordingActionsProps> = ({ recording, uploadFn, ...props }) => {
const { t } = useTranslation();
const context = React.useContext(ServiceContext);
const notifications = React.useContext(NotificationsContext);
const [grafanaEnabled, setGrafanaEnabled] = React.useState(false);
Expand Down Expand Up @@ -111,23 +113,22 @@ export const RecordingActions: React.FC<RecordingActionsProps> = ({ recording, u
isExpanded={isOpen}
variant="plain"
data-quickstart-id="recording-kebab"
aria-label={t('RecordingActions.ARIA_LABELS.MENU_TOGGLE')}
>
<EllipsisVIcon />
</MenuToggle>
),
[setIsOpen, isOpen],
[t, setIsOpen, isOpen],
);

return (
<Td {...props} isActionCell>
<Dropdown
toggle={toggle}
popperProps={{
appendTo: document.body,
enableFlip: true,
position: 'right',
direction: 'down',
}}
aria-label={`${recording.name}-actions`}
isOpen={isOpen}
onOpenChange={(isOpen) => setIsOpen(isOpen)}
onOpenChangeKeys={['Escape']}
Expand Down
2 changes: 1 addition & 1 deletion src/app/Recordings/RecordingFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export const RecordingFilters: React.FC<RecordingFiltersProps> = ({
<FilterIcon />
</Icon>
}
aria-label={currentCategory}
aria-label={t('RecordingFilters.ARIA_LABELS.MENU_TOGGLE')}
onClick={() => onCategoryToggle()}
>
{getCategoryDisplay(t, currentCategory)}
Expand Down
11 changes: 6 additions & 5 deletions src/test/Agent/AgentLiveProbes.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { defaultServices } from '@app/Shared/Services/Services';
import '@testing-library/jest-dom';
import { act, cleanup, screen, within } from '@testing-library/react';
import { of } from 'rxjs';
import { render, renderSnapshot, testT } from '../utils';
import { createMockForPFTableRef, render, renderSnapshot, testT } from '../utils';

const mockConnectUrl = 'service:jmx:rmi://someUrl';
const mockJvmId = 'id';
Expand Down Expand Up @@ -94,7 +94,7 @@ jest

jest
.spyOn(defaultServices.api, 'getActiveProbes')
// .mockReturnValueOnce(of([mockProbe])) // renders correctly
.mockReturnValueOnce(of([mockProbe])) // renders correctly

.mockReturnValueOnce(of([])) // should disable remove button if there is no probe

Expand All @@ -104,8 +104,8 @@ jest

jest
.spyOn(defaultServices.notificationChannel, 'messages')
// .mockReturnValueOnce(of()) // renders correctly
// .mockReturnValueOnce(of())
.mockReturnValueOnce(of()) // renders correctly
.mockReturnValueOnce(of())

.mockReturnValueOnce(of()) // should disable remove button if there is no probe
.mockReturnValueOnce(of())
Expand All @@ -121,9 +121,10 @@ jest
describe('<AgentLiveProbes />', () => {
afterEach(cleanup);

it.skip('renders correctly', async () => {
it('renders correctly', async () => {
const tree = await renderSnapshot({
routerConfigs: { routes: [{ path: '/events', element: <AgentLiveProbes /> }] },
createNodeMock: createMockForPFTableRef,
});
expect(tree?.toJSON()).toMatchSnapshot();
});
Expand Down
Loading

0 comments on commit 45ceb38

Please sign in to comment.