Skip to content

Commit a89f0e5

Browse files
authored
chore: Use FieldHint instead of FieldDescription on create modals (RocketChat#36909)
1 parent 27b29fa commit a89f0e5

11 files changed

Lines changed: 1737 additions & 18 deletions

File tree

apps/meteor/client/NavBarV2/NavBarPagesGroup/actions/CreateChannelModal.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
FieldRow,
1212
FieldError,
1313
FieldHint,
14-
FieldDescription,
1514
Accordion,
1615
AccordionItem,
1716
ModalHeader,
@@ -315,7 +314,7 @@ const CreateChannelModal = ({ teamId = '', onClose, reload }: CreateChannelModal
315314
)}
316315
/>
317316
</FieldRow>
318-
<FieldDescription id={`${encryptedId}-hint`}>{getEncryptedHint({ isPrivate, encrypted })}</FieldDescription>
317+
<FieldHint id={`${encryptedId}-hint`}>{getEncryptedHint({ isPrivate, encrypted })}</FieldHint>
319318
</Field>
320319
<Field>
321320
<FieldRow>

apps/meteor/client/NavBarV2/NavBarPagesGroup/actions/CreateTeamModal.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
FieldLabel,
1111
FieldRow,
1212
FieldError,
13-
FieldDescription,
1413
FieldHint,
1514
Accordion,
1615
AccordionItem,
@@ -241,9 +240,9 @@ const CreateTeamModal = ({ onClose }: CreateTeamModalProps) => {
241240
)}
242241
/>
243242
</FieldRow>
244-
<FieldDescription id={`${privateId}-hint`}>
243+
<FieldHint id={`${privateId}-hint`}>
245244
{isPrivate ? t('People_can_only_join_by_being_invited') : t('Anyone_can_access')}
246-
</FieldDescription>
245+
</FieldHint>
247246
</Field>
248247
</FieldGroup>
249248
<Accordion>
@@ -270,7 +269,7 @@ const CreateTeamModal = ({ onClose }: CreateTeamModalProps) => {
270269
)}
271270
/>
272271
</FieldRow>
273-
<FieldDescription id={`${encryptedId}-hint`}>{getEncryptedHint({ isPrivate, encrypted })}</FieldDescription>
272+
<FieldHint id={`${encryptedId}-hint`}>{getEncryptedHint({ isPrivate, encrypted })}</FieldHint>
274273
</Field>
275274
<Field>
276275
<FieldRow>
@@ -290,9 +289,9 @@ const CreateTeamModal = ({ onClose }: CreateTeamModalProps) => {
290289
)}
291290
/>
292291
</FieldRow>
293-
<FieldDescription id={`${readOnlyId}-hint`}>
292+
<FieldHint id={`${readOnlyId}-hint`}>
294293
{readOnly ? t('Read_only_field_hint_enabled', { roomType: 'team' }) : t('Anyone_can_send_new_messages')}
295-
</FieldDescription>
294+
</FieldHint>
296295
</Field>
297296
<Field>
298297
<FieldRow>
@@ -311,7 +310,7 @@ const CreateTeamModal = ({ onClose }: CreateTeamModalProps) => {
311310
)}
312311
/>
313312
</FieldRow>
314-
{broadcast && <FieldDescription id={`${broadcastId}-hint`}>{t('Teams_New_Broadcast_Description')}</FieldDescription>}
313+
{broadcast && <FieldHint id={`${broadcastId}-hint`}>{t('Teams_New_Broadcast_Description')}</FieldHint>}
315314
</Field>
316315
</FieldGroup>
317316
</AccordionItem>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,28 @@
1+
import { mockAppRoot } from '@rocket.chat/mock-providers';
2+
import { composeStories } from '@storybook/react';
3+
import { render } from '@testing-library/react';
4+
import { axe } from 'jest-axe';
5+
16
import CreateChannelModal from './CreateChannelModal';
7+
import * as stories from './CreateChannelModal.stories';
28
import { testCreateChannelModal } from '../../../NavBarV2/NavBarPagesGroup/actions/testCreateChannelModal';
39

410
jest.mock('../../../lib/utils/goToRoomById', () => ({
511
goToRoomById: jest.fn(),
612
}));
713

814
testCreateChannelModal(CreateChannelModal);
15+
16+
const testCases = Object.values(composeStories(stories)).map((Story) => [Story.storyName || 'Story', Story]);
17+
18+
test.each(testCases)(`renders %s without crashing`, async (_storyname, Story) => {
19+
const { baseElement } = render(<Story />, { wrapper: mockAppRoot().build() });
20+
expect(baseElement).toMatchSnapshot();
21+
});
22+
23+
test.each(testCases)('%s should have no a11y violations', async (_storyname, Story) => {
24+
const { container } = render(<Story />, { wrapper: mockAppRoot().build() });
25+
26+
const results = await axe(container);
27+
expect(results).toHaveNoViolations();
28+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type { Meta, StoryFn } from '@storybook/react';
2+
3+
import CreateChanelModal from './CreateChannelModal';
4+
import CreateChannelModalV2 from '../../../NavBarV2/NavBarPagesGroup/actions/CreateChannelModal';
5+
6+
export default {
7+
title: 'views/sidebar/CreateChanelModal',
8+
component: CreateChanelModal,
9+
} satisfies Meta<typeof CreateChanelModal>;
10+
11+
export const Default: StoryFn<typeof CreateChanelModal> = (args) => <CreateChanelModal {...args} />;
12+
export const DefaultVersion2: StoryFn<typeof CreateChannelModalV2> = (args) => <CreateChannelModalV2 {...args} />;

apps/meteor/client/sidebar/header/CreateChannel/CreateChannelModal.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
FieldRow,
1313
FieldError,
1414
FieldHint,
15-
FieldDescription,
1615
Accordion,
1716
AccordionItem,
1817
ModalHeader,
@@ -311,7 +310,7 @@ const CreateChannelModal = ({ teamId = '', mainRoom, onClose, reload }: CreateCh
311310
)}
312311
/>
313312
</FieldRow>
314-
<FieldDescription id={`${encryptedId}-hint`}>{getEncryptedHint({ isPrivate, encrypted })}</FieldDescription>
313+
<FieldHint id={`${encryptedId}-hint`}>{getEncryptedHint({ isPrivate, encrypted })}</FieldHint>
315314
</Field>
316315
<Field>
317316
<FieldRow>

0 commit comments

Comments
 (0)