Skip to content

Commit 569847d

Browse files
committed
test: add InviteUsers unit tests
1 parent 21d1214 commit 569847d

File tree

3 files changed

+691
-2
lines changed

3 files changed

+691
-2
lines changed

apps/meteor/client/views/room/contextualBar/RoomMembers/InviteUsers/InviteUsers.spec.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ import * as stories from './InviteUsers.stories';
77

88
const testCases = Object.values(composeStories(stories)).map((Story) => [Story.storyName || 'Story', Story]);
99

10+
beforeEach(() => {
11+
jest.mock('react', () => ({
12+
...jest.requireActual('react'),
13+
useId: () => 1,
14+
}));
15+
});
16+
1017
test.each(testCases)(`renders %s without crashing`, async (_storyname, Story) => {
1118
const view = render(<Story />);
1219
expect(view.baseElement).toMatchSnapshot();
@@ -15,6 +22,9 @@ test.each(testCases)(`renders %s without crashing`, async (_storyname, Story) =>
1522
test.each(testCases)('%s should have no a11y violations', async (_storyname, Story) => {
1623
const { container } = render(<Story />);
1724

18-
const results = await axe(container);
25+
/**
26+
** Disable 'nested-interactive' rule because our `Select` component is still not a11y compliant
27+
**/
28+
const results = await axe(container, { rules: { 'nested-interactive': { enabled: false } } });
1929
expect(results).toHaveNoViolations();
2030
});

apps/meteor/client/views/room/contextualBar/RoomMembers/InviteUsers/InviteUsers.stories.tsx

Lines changed: 13 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 type { Meta, StoryFn } from '@storybook/react';
23

34
import InviteUsers from './InviteUsers';
@@ -13,7 +14,18 @@ export default {
1314
layout: 'fullscreen',
1415
actions: { argTypesRegex: '^on.*' },
1516
},
16-
decorators: [(fn) => <Contextualbar height='100vh'>{fn()}</Contextualbar>],
17+
decorators: [
18+
(fn) => <Contextualbar height='100vh'>{fn()}</Contextualbar>,
19+
mockAppRoot()
20+
.withTranslations('en', 'core', {
21+
'Edit_Invite': 'Edit invite',
22+
'Invite_Users': 'Invite users',
23+
'Invite_Link': 'Invite link',
24+
'Expiration_(Days)': 'Expiration (Days)',
25+
'Max_number_of_uses': 'Max number of uses',
26+
})
27+
.buildStoryDecorator(),
28+
],
1729
} satisfies Meta<typeof InviteUsers>;
1830

1931
export const Default: StoryFn<typeof InviteUsers> = (args) => <InviteUsers {...args} />;

0 commit comments

Comments
 (0)