MM-61926 Channel Conversion Text and add test (#29498)

* update text, add tests

* remove commented lines

* lint fix

* i18n-extract

* add additional changes

* update test, change other text

* update test names

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Scott Bishel
2025-01-08 01:04:43 -07:00
коммит произвёл GitHub
родитель 55a7993a11
Коммит b74c2194b2
4 изменённых файлов: 59 добавлений и 9 удалений

Просмотреть файл

@@ -89,7 +89,8 @@ const AllowAllToggle: React.SFC<Props> = (props: Props): JSX.Element | null => {
) : (
<FormattedMessage
id='admin.channel_settings.channel_details.isPublicDescr'
defaultMessage='If `public` the channel is discoverable and any user can join, or if `private` invitations are required. Toggle to convert public channels to private. When Group Sync is enabled, private channels cannot be converted to public.'
defaultMessage='Select Public for a channel any user can find and join. {br}Select Private to require channel invitations to join. {br}Use this switch to change this channel from public to private or from private to public.'
values={{br: (<br/>)}}
/>
)
}

Просмотреть файл

@@ -0,0 +1,55 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {fireEvent, waitForElementToBeRemoved} from '@testing-library/react';
import React from 'react';
import {General} from 'mattermost-redux/constants';
import ConvertChannelModal from 'components/convert_channel_modal/convert_channel_modal';
import {renderWithContext, screen, userEvent} from 'tests/react_testing_utils';
describe('component/ConvertChannelModal', () => {
const updateChannelPrivacy = jest.fn().mockImplementation(() => Promise.resolve({}));
const baseProps = {
onExited: jest.fn(),
channelId: 'owsyt8n43jfxjpzh9np93mx1wa',
channelDisplayName: 'Channel Display Name',
actions: {
updateChannelPrivacy,
},
};
test('should render the title and buttons correctly', () => {
renderWithContext(<ConvertChannelModal {...baseProps}/>);
expect(screen.getByText('Convert Channel Display Name to a Private Channel?')).toBeInTheDocument();
expect(screen.getByRole('button', {name: 'No, cancel'})).toBeInTheDocument();
expect(screen.getByRole('button', {name: 'Yes, convert to private channel'})).toBeInTheDocument();
});
test('should match call updateChannelPrivacy when convert is clicked', () => {
renderWithContext(<ConvertChannelModal {...baseProps}/>);
userEvent.click(screen.getByRole('button', {name: 'Yes, convert to private channel'}));
expect(updateChannelPrivacy).toHaveBeenCalledTimes(1);
expect(updateChannelPrivacy).toHaveBeenCalledWith(baseProps.channelId, General.PRIVATE_CHANNEL);
});
test('should not call updateChannelPrivacy when Close button is clicked', async () => {
renderWithContext(<ConvertChannelModal {...baseProps}/>);
fireEvent.click(screen.getByRole('button', {name: 'Close'}));
await waitForElementToBeRemoved(() => screen.getByText('Convert Channel Display Name to a Private Channel?'));
expect(updateChannelPrivacy).not.toHaveBeenCalled();
});
test('should not call updateChannelPrivacy when other Cancel is clicked', async () => {
renderWithContext(<ConvertChannelModal {...baseProps}/>);
fireEvent.click(screen.getByRole('button', {name: 'No, cancel'}));
await waitForElementToBeRemoved(() => screen.getByText('Convert Channel Display Name to a Private Channel?'));
expect(updateChannelPrivacy).not.toHaveBeenCalled();
});
});

Просмотреть файл

@@ -91,12 +91,6 @@ export default class ConvertChannelModal extends React.PureComponent<Props, Stat
}}
/>
</p>
<p>
<FormattedMessage
id='convert_channel.question2'
defaultMessage='The change is permanent and cannot be undone.'
/>
</p>
<p>
<FormattedMessage
id='convertChannel.question3'
@@ -113,6 +107,7 @@ export default class ConvertChannelModal extends React.PureComponent<Props, Stat
type='button'
className='btn btn-tertiary'
onClick={this.onHide}
data-testid='convertChannelCancel'
>
<FormattedMessage
id='convert_channel.cancel'

Просмотреть файл

@@ -473,7 +473,7 @@
"admin.channel_settings.channel_details.archiveChannel": "Archive Channel",
"admin.channel_settings.channel_details.isDefaultDescr": "This default channel cannot be converted into a private channel.",
"admin.channel_settings.channel_details.isPublic": "Public channel or private channel",
"admin.channel_settings.channel_details.isPublicDescr": "If `public` the channel is discoverable and any user can join, or if `private` invitations are required. Toggle to convert public channels to private. When Group Sync is enabled, private channels cannot be converted to public.",
"admin.channel_settings.channel_details.isPublicDescr": "Select Public for a channel any user can find and join. {br}Select Private to require channel invitations to join. {br}Use this switch to change this channel from public to private or from private to public.",
"admin.channel_settings.channel_details.syncGroupMembers": "Sync Group Members",
"admin.channel_settings.channel_details.syncGroupMembersDescr": "When enabled, adding and removing users from groups will add or remove them from this channel. The only way of inviting members to this channel is by adding the groups they belong to. <link>Learn More</link>",
"admin.channel_settings.channel_details.unarchiveChannel": "Unarchive Channel",
@@ -3460,7 +3460,6 @@
"confirm_switch_to_yearly_modal.title": "Confirm switch to annual plan",
"convert_channel.cancel": "No, cancel",
"convert_channel.confirm": "Yes, convert to private channel",
"convert_channel.question2": "The change is permanent and cannot be undone.",
"convert_channel.title": "Convert {display_name} to a Private Channel?",
"convertChannel.question1": "When you convert <b>{display_name}</b> to a private channel, history and membership are preserved. Publicly shared files remain accessible to anyone with the link. Membership in a private channel is by invitation only.",
"convertChannel.question3": "Are you sure you want to convert <b>{display_name}</b> to a private channel?",