Skip to content

Commit f1091be

Browse files
authored
test(ui-client): clear up runtime warnings (#40772)
1 parent 5ef921e commit f1091be

5 files changed

Lines changed: 24 additions & 12 deletions

File tree

packages/ui-client/src/components/InfoPanel/InfoPanelLabel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ type InfoPanelLabelProps = ComponentPropsWithoutRef<typeof Box>;
66
const InfoPanelLabel = ({ title, children, ...props }: InfoPanelLabelProps) => (
77
<Box mb={8} fontScale='p2m' color='default' {...props}>
88
{children}
9-
{title && <Icon name='info' color='font-secondary-info' mi={4} size='x16' title={title} />}
9+
{title && <Icon name='info' color='secondary-info' mi={4} size='x16' title={title} />}
1010
</Box>
1111
);
1212

packages/ui-client/src/components/Modal/GenericModal/GenericModal.spec.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { mockAppRoot } from '@rocket.chat/mock-providers';
12
import { useSetModal } from '@rocket.chat/ui-contexts';
23
import { act, screen, renderHook } from '@testing-library/react';
34
import userEvent from '@testing-library/user-event';
@@ -12,11 +13,13 @@ const renderModal = (modalElement: ReactElement) => {
1213
const {
1314
result: { current: setModal },
1415
} = renderHook(() => useSetModal(), {
15-
wrapper: ({ children }) => (
16-
<Suspense fallback={null}>
17-
<ModalProviderWithRegion>{children}</ModalProviderWithRegion>
18-
</Suspense>
19-
),
16+
wrapper: mockAppRoot()
17+
.wrap((children) => (
18+
<Suspense fallback={null}>
19+
<ModalProviderWithRegion>{children}</ModalProviderWithRegion>
20+
</Suspense>
21+
))
22+
.build(),
2023
});
2124

2225
act(() => {

packages/ui-client/src/components/Wizard/Wizard.spec.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { mockAppRoot } from '@rocket.chat/mock-providers';
12
import { composeStories } from '@storybook/react';
23
import { render } from '@testing-library/react';
34
import { axe } from 'jest-axe';
@@ -7,12 +8,16 @@ import * as stories from './Wizard.stories';
78
const testCases = Object.values(composeStories(stories)).map((Story) => [Story.storyName || 'Story', Story]);
89

910
test.each(testCases)(`renders %s without crashing`, async (_storyname, Story) => {
10-
const { baseElement } = render(<Story />);
11+
const { baseElement } = render(<Story />, {
12+
wrapper: mockAppRoot().build(),
13+
});
1114
expect(baseElement).toMatchSnapshot();
1215
});
1316

1417
test.each(testCases)('%s should have no a11y violations', async (_storyname, Story) => {
15-
const { container } = render(<Story />);
18+
const { container } = render(<Story />, {
19+
wrapper: mockAppRoot().build(),
20+
});
1621

1722
const results = await axe(container);
1823
expect(results).toHaveNoViolations();

packages/ui-client/src/components/Wizard/WizardActions.spec.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { mockAppRoot } from '@rocket.chat/mock-providers';
12
import { composeStories } from '@storybook/react';
23
import { render } from '@testing-library/react';
34
import { axe } from 'jest-axe';
@@ -7,12 +8,12 @@ import * as stories from './WizardActions.stories';
78
const testCases = Object.values(composeStories(stories)).map((Story) => [Story.storyName || 'Story', Story]);
89

910
test.each(testCases)(`renders %s without crashing`, async (_storyname, Story) => {
10-
const tree = render(<Story />);
11-
expect(tree.baseElement).toMatchSnapshot();
11+
const view = render(<Story />, { wrapper: mockAppRoot().build() });
12+
expect(view.baseElement).toMatchSnapshot();
1213
});
1314

1415
test.each(testCases)('%s should have no a11y violations', async (_storyname, Story) => {
15-
const { container } = render(<Story />);
16+
const { container } = render(<Story />, { wrapper: mockAppRoot().build() });
1617

1718
const results = await axe(container);
1819
expect(results).toHaveNoViolations();

packages/ui-client/src/providers/ModalProvider/ModalProvider.spec.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { mockAppRoot } from '@rocket.chat/mock-providers';
12
import { useSetModal } from '@rocket.chat/ui-contexts';
23
import { act, render, screen } from '@testing-library/react';
34
import type { ForwardedRef, ReactElement } from 'react';
@@ -11,7 +12,9 @@ import { imperativeModal } from '../../helpers/imperativeModal';
1112

1213
const renderWithSuspense = (ui: ReactElement) =>
1314
render(ui, {
14-
wrapper: ({ children }) => <Suspense fallback={null}>{children}</Suspense>,
15+
wrapper: mockAppRoot()
16+
.wrap((children) => <Suspense fallback={null}>{children}</Suspense>)
17+
.build(),
1518
});
1619

1720
describe('via useSetModal', () => {

0 commit comments

Comments
 (0)