From c0dcaf2cd676971c3da7b16d805b8e8f5794002d Mon Sep 17 00:00:00 2001 From: sabril <5334504+saturninoabril@users.noreply.github.com> Date: Fri, 27 Mar 2026 01:30:16 +0800 Subject: [PATCH] MM-68021 H10-17 Enzyme to RTL bulk migration (#35735) * (test): h10-17 enzyme to rtl bulk migration * address comments and fix lint * update per comments --- ...om_terms_of_service_settings.test.tsx.snap | 314 +- .../custom_terms_of_service_settings.test.tsx | 103 +- .../admin_console/filter/filter.tsx | 5 +- .../admin_console/filter/filter_list.test.tsx | 50 + .../admin_console/filter/filter_list.tsx | 2 +- .../team_filter_dropdown.test.tsx | 122 + .../team_filter_dropdown.tsx | 6 +- .../__snapshots__/system_roles.test.tsx.snap | 139 +- .../__snapshots__/system_role.test.tsx.snap | 206 +- .../system_role_permission.test.tsx.snap | 74 +- ...tem_role_permission_dropdown.test.tsx.snap | 261 +- .../system_role_permissions.test.tsx.snap | 1871 +++++--- .../system_role/system_role.test.tsx | 31 +- .../system_role_permission.test.tsx | 13 +- .../system_role_permission_dropdown.test.tsx | 17 +- .../system_role_permissions.test.tsx | 49 +- .../system_role_users.test.tsx.snap | 1082 ++--- .../system_role_users.test.tsx | 50 +- .../system_roles/system_roles.test.tsx | 9 +- .../__snapshots__/abstract_list.test.tsx.snap | 209 +- .../abstract_list.test.tsx | 30 +- .../channel_settings.test.tsx.snap | 72 +- .../channel/channel_settings.test.tsx | 9 +- .../channel_details.test.tsx.snap | 2834 ++++++++---- .../channel_groups.test.tsx.snap | 185 +- .../channel_moderation.test.tsx.snap | 1735 +++++--- .../__snapshots__/channel_modes.test.tsx.snap | 279 +- .../channel_profile.test.tsx.snap | 235 +- .../channel/details/channel_details.test.tsx | 447 +- .../channel/details/channel_groups.test.tsx | 7 +- .../channel_members.test.tsx.snap | 902 ++-- .../channel_members/channel_members.test.tsx | 18 +- .../details/channel_moderation.test.tsx | 275 +- .../channel/details/channel_modes.test.tsx | 11 +- .../channel/details/channel_profile.test.tsx | 10 +- .../__snapshots__/channel_list.test.tsx.snap | 3934 +++++++++++------ .../channel/list/channel_list.test.tsx | 79 +- .../__snapshots__/group_list.test.tsx.snap | 1264 +++--- .../group_members_modal.test.tsx.snap | 192 +- .../__snapshots__/group_row.test.tsx.snap | 142 +- .../group/group_list.test.tsx | 44 +- .../group/group_members_modal.test.tsx | 9 +- .../group/group_row.test.tsx | 8 +- .../users_to_remove.test.tsx.snap | 1125 +++-- .../users_to_remove_groups.test.tsx.snap | 48 +- .../group_users/users_to_remove.test.tsx | 71 +- .../users_to_remove_groups.test.tsx | 17 +- .../__snapshots__/team_settings.test.tsx.snap | 65 +- .../__snapshots__/team_details.test.tsx.snap | 384 +- .../__snapshots__/team_groups.test.tsx.snap | 223 +- .../__snapshots__/team_modes.test.tsx.snap | 155 +- .../team/details/team_details.test.tsx | 18 +- .../team/details/team_groups.test.tsx | 6 +- .../__snapshots__/team_members.test.tsx.snap | 873 ++-- .../team_members/team_members.test.tsx | 18 +- .../team/details/team_modes.test.tsx | 7 +- .../team/team_settings.test.tsx | 9 +- webapp/channels/src/tests/CLAUDE.OPTIONAL.md | 16 + 58 files changed, 12226 insertions(+), 8143 deletions(-) create mode 100644 webapp/channels/src/components/admin_console/filter/filter_list.test.tsx create mode 100644 webapp/channels/src/components/admin_console/filter/team_filter_dropdown/team_filter_dropdown.test.tsx diff --git a/webapp/channels/src/components/admin_console/custom_terms_of_service_settings/__snapshots__/custom_terms_of_service_settings.test.tsx.snap b/webapp/channels/src/components/admin_console/custom_terms_of_service_settings/__snapshots__/custom_terms_of_service_settings.test.tsx.snap index a4b1be851b9..ae1a7fad8ed 100644 --- a/webapp/channels/src/components/admin_console/custom_terms_of_service_settings/__snapshots__/custom_terms_of_service_settings.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/custom_terms_of_service_settings/__snapshots__/custom_terms_of_service_settings.test.tsx.snap @@ -1,185 +1,159 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`components/admin_console/CustomTermsOfServiceSettings should match snapshot 1`] = ` -
-
+ - - - -
- - } - /> - + Custom Terms of Service +
+
- +
+ + Enable Custom Terms of Service + +
+ + +
+ When true, new users must accept the terms of service before accessing any Mattermost teams on desktop, web or mobile. Existing users must accept them after login or a page refresh. To update terms of service link displayed in account creation and login pages, go to + + Site Configuration > Customization + +
+
+
+
+ +
+ +
+ Text that will appear in your custom Terms of Service. Supports Markdown-formatted text. +
+
+
+
+ +
+ +
+ The number of days before Terms of Service acceptance expires, and the terms must be re-accepted. +
+
+
- -
-
-
-`; - -exports[`components/admin_console/CustomTermsOfServiceSettings should match snapshot 2`] = ` -
-
- - - - -
- - } - /> - +
-
- -
- -
-
- -`; - -exports[`components/admin_console/CustomTermsOfServiceSettings should match snapshot 3`] = ` -
-
- - - - -
- - } - /> - + + Save + +
- -
-
+ class="error-message" + /> +
-
- -`; - -exports[`components/admin_console/CustomTermsOfServiceSettings should match snapshot 4`] = ` -
-
- - - - -
- - } - /> - -
- -
-
-
-
-
+ + `; diff --git a/webapp/channels/src/components/admin_console/custom_terms_of_service_settings/custom_terms_of_service_settings.test.tsx b/webapp/channels/src/components/admin_console/custom_terms_of_service_settings/custom_terms_of_service_settings.test.tsx index 3230b6f0a48..6805345a6ec 100644 --- a/webapp/channels/src/components/admin_console/custom_terms_of_service_settings/custom_terms_of_service_settings.test.tsx +++ b/webapp/channels/src/components/admin_console/custom_terms_of_service_settings/custom_terms_of_service_settings.test.tsx @@ -1,15 +1,17 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {shallow} from 'enzyme'; +import {screen, waitFor} from '@testing-library/react'; import React from 'react'; import type {AdminConfig} from '@mattermost/types/config'; import CustomTermsOfServiceSettings from 'components/admin_console/custom_terms_of_service_settings/custom_terms_of_service_settings'; +import {renderWithContext, userEvent} from 'tests/react_testing_utils'; + describe('components/admin_console/CustomTermsOfServiceSettings', () => { - const baseProps = { + const getBaseProps = () => ({ actions: { createTermsOfService: jest.fn(), getTermsOfService: jest.fn().mockResolvedValue({data: {id: 'tos_id', text: 'tos_text'}}), @@ -26,24 +28,99 @@ describe('components/admin_console/CustomTermsOfServiceSettings', () => { }, setNavigationBlocked: jest.fn(), patchConfig: jest.fn(), - }; + }); - test('should match snapshot', () => { - const wrapper = shallow( + async function renderLoaded(props: ReturnType) { + const view = renderWithContext( , ); + expect(await screen.findByText('Enable Custom Terms of Service')).toBeInTheDocument(); + return view; + } - expect(wrapper).toMatchSnapshot(); + test('should match snapshot', async () => { + const props = getBaseProps(); + const {container} = await renderLoaded(props); - wrapper.setProps({saveNeeded: true}); - expect(wrapper).toMatchSnapshot(); + expect(container).toMatchSnapshot(); + }); - wrapper.setProps({saveNeeded: false, saving: true}); - expect(wrapper).toMatchSnapshot(); + test('save button is disabled until a setting is changed, then enabled after edit', async () => { + const user = userEvent.setup(); + const props = getBaseProps(); + await renderLoaded(props); - wrapper.setProps({saving: false, serverError: 'error'}); - expect(wrapper).toMatchSnapshot(); + const saveButton = screen.getByTestId('saveSetting'); + expect(saveButton).toBeDisabled(); + + const periodInput = screen.getByTestId('SupportSettings.CustomTermsOfServiceReAcceptancePeriodnumber'); + await user.clear(periodInput); + await user.type(periodInput, '364'); + + await waitFor(() => { + expect(saveButton).not.toBeDisabled(); + }); + }); + + test('shows saving state on the save button while patchConfig is in progress', async () => { + const user = userEvent.setup(); + const props = getBaseProps(); + + let resolvePatch!: (value: {data: AdminConfig; error?: undefined}) => void; + props.patchConfig = jest.fn( + () => + new Promise((resolve) => { + resolvePatch = resolve; + }), + ); + + await renderLoaded(props); + + const periodInput = screen.getByTestId('SupportSettings.CustomTermsOfServiceReAcceptancePeriodnumber'); + await user.clear(periodInput); + await user.type(periodInput, '364'); + + await user.click(screen.getByTestId('saveSetting')); + + expect(await screen.findByText('Saving Config...')).toBeInTheDocument(); + + const savedConfig = JSON.parse(JSON.stringify(props.config)) as AdminConfig; + savedConfig.SupportSettings!.CustomTermsOfServiceReAcceptancePeriod = 364; + + resolvePatch({data: savedConfig}); + + await waitFor(() => { + expect(screen.queryByText('Saving Config...')).not.toBeInTheDocument(); + }); + + expect(props.patchConfig).toHaveBeenCalledTimes(1); + }); + + test('shows server error when patchConfig returns an error', async () => { + const user = userEvent.setup(); + const props = getBaseProps(); + props.patchConfig = jest.fn().mockResolvedValue({ + data: undefined, + error: { + message: 'error', + server_error_id: 'test.patch_config.error', + }, + }); + + await renderLoaded(props); + + const periodInput = screen.getByTestId('SupportSettings.CustomTermsOfServiceReAcceptancePeriodnumber'); + await user.clear(periodInput); + await user.type(periodInput, '364'); + + await user.click(screen.getByTestId('saveSetting')); + + expect(await screen.findByText('error')).toBeInTheDocument(); + + await waitFor(() => { + expect(screen.queryByText('Saving Config...')).not.toBeInTheDocument(); + }); }); }); diff --git a/webapp/channels/src/components/admin_console/filter/filter.tsx b/webapp/channels/src/components/admin_console/filter/filter.tsx index 878d08b9ef7..baa9ee181a7 100644 --- a/webapp/channels/src/components/admin_console/filter/filter.tsx +++ b/webapp/channels/src/components/admin_console/filter/filter.tsx @@ -32,8 +32,9 @@ export type FilterOption = { // Key value map of filter values with keys matching the keys above values: FilterValues; - // Filter Component type, optional parameter defaults to FilterCheckbox - type?: React.ElementType; + // Filter component constructor (use ComponentType, not ElementType: babel-plugin-typescript-to-proptypes maps + // ElementType to PropTypes.node, which breaks runtime validation for custom filter UIs such as TeamFilterDropdown). + type?: React.ComponentType; } export type FilterOptions = { diff --git a/webapp/channels/src/components/admin_console/filter/filter_list.test.tsx b/webapp/channels/src/components/admin_console/filter/filter_list.test.tsx new file mode 100644 index 00000000000..c2a7a3e492b --- /dev/null +++ b/webapp/channels/src/components/admin_console/filter/filter_list.test.tsx @@ -0,0 +1,50 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import {screen} from '@testing-library/react'; +import React from 'react'; + +import {renderWithContext} from 'tests/react_testing_utils'; + +import type {FilterOption} from './filter'; +import FilterList from './filter_list'; + +describe('admin_console/filter/FilterList', () => { + const baseOption: FilterOption = { + name: 'Test Filter', + keys: ['opt1', 'opt2'], + values: { + opt1: {name: 'Option 1', value: true}, + opt2: {name: 'Option 2', value: false}, + }, + }; + + test('should render filter name and labels', () => { + renderWithContext( + , + ); + + expect(screen.getByText('Test Filter')).toBeInTheDocument(); + expect(screen.getByText('Option 1')).toBeInTheDocument(); + expect(screen.getByText('Option 2')).toBeInTheDocument(); + }); + + test('should render checkboxes matching boolean values', () => { + renderWithContext( + , + ); + + const checkboxes = screen.getAllByRole('checkbox'); + expect(checkboxes).toHaveLength(2); + expect(checkboxes[0]).toBeChecked(); + expect(checkboxes[1]).not.toBeChecked(); + }); +}); diff --git a/webapp/channels/src/components/admin_console/filter/filter_list.tsx b/webapp/channels/src/components/admin_console/filter/filter_list.tsx index 1f5d1bc4252..acc04c33579 100644 --- a/webapp/channels/src/components/admin_console/filter/filter_list.tsx +++ b/webapp/channels/src/components/admin_console/filter/filter_list.tsx @@ -43,7 +43,7 @@ const FilterList = ({ diff --git a/webapp/channels/src/components/admin_console/filter/team_filter_dropdown/team_filter_dropdown.test.tsx b/webapp/channels/src/components/admin_console/filter/team_filter_dropdown/team_filter_dropdown.test.tsx new file mode 100644 index 00000000000..6f5699883ac --- /dev/null +++ b/webapp/channels/src/components/admin_console/filter/team_filter_dropdown/team_filter_dropdown.test.tsx @@ -0,0 +1,122 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import {screen, waitFor} from '@testing-library/react'; +import React from 'react'; + +import {renderWithContext} from 'tests/react_testing_utils'; + +import TeamFilterDropdown from './team_filter_dropdown'; + +import type {FilterOption} from '../filter'; + +describe('admin_console/filter/team_filter_dropdown/TeamFilterDropdown', () => { + const getBaseProps = () => ({ + getTeams: jest.fn().mockResolvedValue({data: {teams: [ + {id: 'team-1', display_name: 'Alpha Team'}, + {id: 'team-2', display_name: 'Beta Team'}, + ]}}), + searchTeams: jest.fn().mockResolvedValue({data: {teams: []}}), + updateValues: jest.fn(), + }); + + test('should render filter name and load teams on mount', async () => { + const props = getBaseProps(); + const option: FilterOption = { + name: 'Teams', + keys: ['team_ids'], + values: { + team_ids: {name: 'Teams', value: [] as string[]}, + }, + }; + + renderWithContext( + , + ); + + expect(screen.getByText('Teams')).toBeInTheDocument(); + expect(screen.getByText('Search and select teams')).toBeInTheDocument(); + + await waitFor(() => { + expect(props.getTeams).toHaveBeenCalledTimes(1); + }); + }); + + test('should show selected teams when team_ids match loaded teams', async () => { + const props = getBaseProps(); + const option: FilterOption = { + name: 'Teams', + keys: ['team_ids'], + values: { + team_ids: {name: 'Teams', value: ['team-1']}, + }, + }; + + renderWithContext( + , + ); + + await waitFor(() => { + expect(props.getTeams).toHaveBeenCalledTimes(1); + }); + + expect(screen.getByText('Alpha Team')).toBeInTheDocument(); + }); + + test('should show no selected teams when team_ids value is undefined', async () => { + const props = getBaseProps(); + const option: FilterOption = { + name: 'Teams', + keys: ['team_ids'], + values: {}, + }; + + renderWithContext( + , + ); + + await waitFor(() => { + expect(props.getTeams).toHaveBeenCalledTimes(1); + }); + + expect(screen.queryByText('Alpha Team')).not.toBeInTheDocument(); + expect(screen.queryByText('Beta Team')).not.toBeInTheDocument(); + expect(screen.getByText('Search and select teams')).toBeInTheDocument(); + }); + + test('should show no selected teams when team_ids value is a non-array', async () => { + const props = getBaseProps(); + const option: FilterOption = { + name: 'Teams', + keys: ['team_ids'], + values: { + team_ids: {name: 'Teams', value: true}, + }, + }; + + renderWithContext( + , + ); + + await waitFor(() => { + expect(props.getTeams).toHaveBeenCalledTimes(1); + }); + + // Non-array falls back to [], so no teams selected despite teams being loaded + expect(screen.queryByText('Alpha Team')).not.toBeInTheDocument(); + expect(screen.queryByText('Beta Team')).not.toBeInTheDocument(); + expect(screen.getByText('Search and select teams')).toBeInTheDocument(); + }); +}); diff --git a/webapp/channels/src/components/admin_console/filter/team_filter_dropdown/team_filter_dropdown.tsx b/webapp/channels/src/components/admin_console/filter/team_filter_dropdown/team_filter_dropdown.tsx index 62905e564db..d065fa42c5f 100644 --- a/webapp/channels/src/components/admin_console/filter/team_filter_dropdown/team_filter_dropdown.tsx +++ b/webapp/channels/src/components/admin_console/filter/team_filter_dropdown/team_filter_dropdown.tsx @@ -22,6 +22,9 @@ type TeamSelectOption = {label: string; value: string} export interface Props extends PropsFromRedux { option: FilterOption; + + /** Passed by `Filter` for all filter list components; unused here. */ + optionKey?: string; updateValues: (values: FilterValues, optionKey: string) => void; } @@ -99,7 +102,8 @@ function TeamFilterDropdown(props: Props) { loadListInPageNumber(0); }, []); - const optionValues = props.option.values?.team_ids?.value as string[]; + const rawTeamIds = props.option.values?.team_ids?.value; + const optionValues = Array.isArray(rawTeamIds) ? rawTeamIds : []; const selectedValues = list.filter((item) => optionValues.includes(item.value)); return ( diff --git a/webapp/channels/src/components/admin_console/system_roles/__snapshots__/system_roles.test.tsx.snap b/webapp/channels/src/components/admin_console/system_roles/__snapshots__/system_roles.test.tsx.snap index 5af54c20656..1af85e9479e 100644 --- a/webapp/channels/src/components/admin_console/system_roles/__snapshots__/system_roles.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/system_roles/__snapshots__/system_roles.test.tsx.snap @@ -1,108 +1,59 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`admin_console/system_roles should match snapshot 1`] = ` -
- - - +
- +
+
- , - "edit": - - - - , - "role": , - "type": , - }, - "onClick": [Function], - }, - ] - } - startCount={0} - term="" - /> +
+
+

+ Admin Roles +

+
+ Manage different levels of access to the system console. +
+
+
+
+
+
+
+
+
+
+
- +
diff --git a/webapp/channels/src/components/admin_console/system_roles/system_role/__snapshots__/system_role.test.tsx.snap b/webapp/channels/src/components/admin_console/system_roles/system_role/__snapshots__/system_role.test.tsx.snap index 948527483ce..6e8c9a62cf4 100644 --- a/webapp/channels/src/components/admin_console/system_roles/system_role/__snapshots__/system_role.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/system_roles/system_role/__snapshots__/system_role.test.tsx.snap @@ -1,125 +1,127 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`admin_console/system_role should match snapshot 1`] = ` -
- -
- - role_name -
-
+ `; exports[`admin_console/system_role should match snapshot with isLicensedForCloud = true 1`] = ` -
- -
- - role_name -
-
+ `; diff --git a/webapp/channels/src/components/admin_console/system_roles/system_role/__snapshots__/system_role_permission.test.tsx.snap b/webapp/channels/src/components/admin_console/system_roles/system_role/__snapshots__/system_role_permission.test.tsx.snap index b6fd5f0b99a..b4a85eb5cc9 100644 --- a/webapp/channels/src/components/admin_console/system_roles/system_role/__snapshots__/system_role_permission.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/system_roles/system_role/__snapshots__/system_role_permission.test.tsx.snap @@ -1,50 +1,58 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`admin_console/system_role_permission should match snapshot 1`] = ` -
+
- +
+ Environment +
+
+ Review server environment configuration such as URLs, database and performance. +
- +
-
- -
`; diff --git a/webapp/channels/src/components/admin_console/system_roles/system_role/__snapshots__/system_role_permission_dropdown.test.tsx.snap b/webapp/channels/src/components/admin_console/system_roles/system_role/__snapshots__/system_role_permission_dropdown.test.tsx.snap index 2b2c911c347..9ccc02e6419 100644 --- a/webapp/channels/src/components/admin_console/system_roles/system_role/__snapshots__/system_role_permission_dropdown.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/system_roles/system_role/__snapshots__/system_role_permission_dropdown.test.tsx.snap @@ -1,223 +1,60 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`admin_console/system_role_permission_dropdown should match snapshot 1`] = ` - - - - -
- -
-
- -
-
- } - /> - -
- -
-
- -
-
- } - /> - -
- -
-
- -
-
- } - /> - - +
+ Read only +
+
+ +
+ +
+
`; exports[`admin_console/system_role_permission_dropdown should match snapshot with isDisabledTrue 1`] = ` - - - - -
- -
-
- -
-
- } - /> - -
- -
-
- -
-
- } - /> - -
- -
-
- -
- - } - /> - - +
+ Read only +
+
+ +
+ + + `; diff --git a/webapp/channels/src/components/admin_console/system_roles/system_role/__snapshots__/system_role_permissions.test.tsx.snap b/webapp/channels/src/components/admin_console/system_roles/system_role/__snapshots__/system_role_permissions.test.tsx.snap index 29acac94260..865fc5d63d2 100644 --- a/webapp/channels/src/components/admin_console/system_roles/system_role/__snapshots__/system_role_permissions.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/system_roles/system_role/__snapshots__/system_role_permissions.test.tsx.snap @@ -1,714 +1,1183 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`admin_console/system_role_permissions should match snapshot 1`] = ` - +
- - - - - - - - - - +
+
+

+ Privileges +

+
+ Level of access to the system console. +
+
+
+
+
+
+
+
+ About +
+
+ The ability to install or upgrade your servers enterprise licensing. +
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ Reporting +
+
+ Review site statistics, team statistics and server logs. +
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ User Management +
+
+ Review users, groups, teams, channels, permissions and system roles. +
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ Environment +
+
+ Review server environment configuration such as URLs, database and performance. +
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ Site Configuration +
+
+ Review site specific configurations such as site name, notification defaults and file sharing. +
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ Authentication +
+
+ Review the configuration around how users can signup and access Mattermost. +
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ Plugins +
+
+ Review installed plugins and their configuration. +
+
+
+ +
+
+
+
+
+
+
+ Integrations +
+
+ Review integration configurations such as webhooks, bots and cross-origin requests. +
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ Compliance +
+
+ Review compliance settings such as retention, exports and activity logs. +
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ Experimental +
+
+ Review the settings of experimental features +
+
+ +
+
+
+ +
+
+
+
+
- +
`; exports[`admin_console/system_role_permissions should match snapshot with isLicensedForCloud = true 1`] = ` - +
- - - - - - - - +
+
+

+ Privileges +

+
+ Level of access to the system console. +
+
+
+
+
+
+
+
+ Reporting +
+
+ Review site statistics, team statistics and server logs. +
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ User Management +
+
+ Review users, groups, teams, channels, permissions and system roles. +
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ Site Configuration +
+
+ Review site specific configurations such as site name, notification defaults and file sharing. +
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ Authentication +
+
+ Review the configuration around how users can signup and access Mattermost. +
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ Plugins +
+
+ Review installed plugins and their configuration. +
+
+
+ +
+
+
+
+
+
+
+ Integrations +
+
+ Review integration configurations such as webhooks, bots and cross-origin requests. +
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ Compliance +
+
+ Review compliance settings such as retention, exports and activity logs. +
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ Experimental +
+
+ Review the settings of experimental features +
+
+ +
+
+
+ +
+
+
+
+
- +
`; diff --git a/webapp/channels/src/components/admin_console/system_roles/system_role/system_role.test.tsx b/webapp/channels/src/components/admin_console/system_roles/system_role/system_role.test.tsx index d8b296ca97c..ac7554e7e96 100644 --- a/webapp/channels/src/components/admin_console/system_roles/system_role/system_role.test.tsx +++ b/webapp/channels/src/components/admin_console/system_roles/system_role/system_role.test.tsx @@ -1,13 +1,28 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {shallow} from 'enzyme'; import React from 'react'; +import {renderWithContext} from 'tests/react_testing_utils'; import {TestHelper} from 'utils/test_helper'; import SystemRole from './system_role'; +jest.mock('./system_role_permissions', () => { + return function MockSystemRolePermissions(props: {role: {name: string}}) { + return
{`Permissions for ${props.role.name}`}
; + }; +}); + +jest.mock('./system_role_users', () => { + return { + __esModule: true, + default: function MockSystemRoleUsers(props: {roleName: string}) { + return
{`Users for ${props.roleName}`}
; + }, + }; +}); + describe('admin_console/system_role', () => { const props = { role: TestHelper.getRoleMock(), @@ -21,21 +36,23 @@ describe('admin_console/system_role', () => { }; test('should match snapshot', () => { - const wrapper = shallow( + const {container} = renderWithContext( ); + />, + ); - expect(wrapper).toMatchSnapshot(); + expect(container).toMatchSnapshot(); }); test('should match snapshot with isLicensedForCloud = true', () => { - const wrapper = shallow( + const {container} = renderWithContext( ); + />, + ); - expect(wrapper).toMatchSnapshot(); + expect(container).toMatchSnapshot(); }); }); diff --git a/webapp/channels/src/components/admin_console/system_roles/system_role/system_role_permission.test.tsx b/webapp/channels/src/components/admin_console/system_roles/system_role/system_role_permission.test.tsx index e6da4e8457a..d6c7c61adf6 100644 --- a/webapp/channels/src/components/admin_console/system_roles/system_role/system_role_permission.test.tsx +++ b/webapp/channels/src/components/admin_console/system_roles/system_role/system_role_permission.test.tsx @@ -1,10 +1,9 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {shallow} from 'enzyme'; import React from 'react'; -import {TestHelper} from 'utils/test_helper'; +import {renderWithContext} from 'tests/react_testing_utils'; import SystemRolePermission from './system_role_permission'; import {readAccess} from './types'; @@ -27,16 +26,14 @@ describe('admin_console/system_role_permission', () => { environment: readAccess, }, updatePermissions: jest.fn(), - roles: { - system_admin: TestHelper.getRoleMock(), - }, }; - const wrapper = shallow( + const {container} = renderWithContext( ); + />, + ); - expect(wrapper).toMatchSnapshot(); + expect(container).toMatchSnapshot(); }); }); diff --git a/webapp/channels/src/components/admin_console/system_roles/system_role/system_role_permission_dropdown.test.tsx b/webapp/channels/src/components/admin_console/system_roles/system_role/system_role_permission_dropdown.test.tsx index 583bc4e4a8b..be83cc07d2b 100644 --- a/webapp/channels/src/components/admin_console/system_roles/system_role/system_role_permission_dropdown.test.tsx +++ b/webapp/channels/src/components/admin_console/system_roles/system_role/system_role_permission_dropdown.test.tsx @@ -1,9 +1,10 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {shallow} from 'enzyme'; import React from 'react'; +import {renderWithContext} from 'tests/react_testing_utils'; + import SystemRolePermissionDropdown from './system_role_permission_dropdown'; import {readAccess} from './types'; @@ -20,21 +21,23 @@ describe('admin_console/system_role_permission_dropdown', () => { }; test('should match snapshot', () => { - const wrapper = shallow( + const {container} = renderWithContext( ); + />, + ); - expect(wrapper).toMatchSnapshot(); + expect(container).toMatchSnapshot(); }); test('should match snapshot with isDisabledTrue', () => { - const wrapper = shallow( + const {container} = renderWithContext( ); + />, + ); - expect(wrapper).toMatchSnapshot(); + expect(container).toMatchSnapshot(); }); }); diff --git a/webapp/channels/src/components/admin_console/system_roles/system_role/system_role_permissions.test.tsx b/webapp/channels/src/components/admin_console/system_roles/system_role/system_role_permissions.test.tsx index 020d4d9d574..7a88d29916b 100644 --- a/webapp/channels/src/components/admin_console/system_roles/system_role/system_role_permissions.test.tsx +++ b/webapp/channels/src/components/admin_console/system_roles/system_role/system_role_permissions.test.tsx @@ -1,12 +1,12 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {shallow} from 'enzyme'; +import {screen} from '@testing-library/react'; import React from 'react'; +import {renderWithContext} from 'tests/react_testing_utils'; import {TestHelper} from 'utils/test_helper'; -import SystemRolePermission from './system_role_permission'; import SystemRolePermissions from './system_role_permissions'; import {readAccess, writeAccess} from './types'; @@ -23,38 +23,49 @@ describe('admin_console/system_role_permissions', () => { }; test('should match snapshot', () => { - const wrapper = shallow( + const {container} = renderWithContext( ); + />, + ); - expect(wrapper).toMatchSnapshot(); + expect(container).toMatchSnapshot(); }); test('should match snapshot with isLicensedForCloud = true', () => { - const wrapper = shallow( + const {container} = renderWithContext( ); + />, + ); - expect(wrapper).toMatchSnapshot(); + expect(container).toMatchSnapshot(); }); test('ensure that when you change a prop and component is re-rendered, SystemRolePermission is not being deleted due to isLicensedForCloud being false (test for bug MM-31403)', () => { - const wrapper = shallow( + const {rerender} = renderWithContext( ); + />, + ); - const expectedLength = 8; - let systemRolePermissionLength = wrapper.find(SystemRolePermission).length; - expect(systemRolePermissionLength).toEqual(expectedLength); - wrapper.setProps({permissionToUpdate: { - environment: writeAccess, - plugins: readAccess, - }}); - systemRolePermissionLength = wrapper.find(SystemRolePermission).length; - expect(systemRolePermissionLength).toEqual(expectedLength); + // Count the permission sections rendered + const getSectionCount = () => screen.getAllByTestId(/^permission_section_/).length; + + const expectedLength = getSectionCount(); + + // Re-render with updated permissions + rerender( + , + ); + + expect(getSectionCount()).toEqual(expectedLength); }); }); diff --git a/webapp/channels/src/components/admin_console/system_roles/system_role/system_role_users/__snapshots__/system_role_users.test.tsx.snap b/webapp/channels/src/components/admin_console/system_roles/system_role/system_role_users/__snapshots__/system_role_users.test.tsx.snap index 151465c7096..d2ef09e2ab1 100644 --- a/webapp/channels/src/components/admin_console/system_roles/system_role/system_role_users/__snapshots__/system_role_users.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/system_roles/system_role/system_role_users/__snapshots__/system_role_users.test.tsx.snap @@ -1,735 +1,365 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`admin_console/system_role_users should match snapshot 1`] = ` - +
+
- - - } - id="SystemRoleUsers" - subtitle={ - Object { - "defaultMessage": "List of people assigned to this system role.", - "id": "admin.permissions.system_role_users.description", - } - } - title={ - Object { - "defaultMessage": "Assigned People", - "id": "admin.permissions.system_role_users.title", - } - } -> - , - "width": 3, - }, - Object { - "field": "new", - "fixed": true, - "name": "", - "width": 1, - }, - Object { - "field": "remove", - "fixed": true, - "name": "", - "textAlign": "right", - }, - ] - } - endCount={2} - loading={true} - nextPage={[Function]} - onSearch={[Function]} - previousPage={[Function]} - rows={ - Array [ - Object { - "cells": Object { - "id": "user_id", - "name": , - "new": null, - "remove": , - }, - }, - Object { - "cells": Object { - "id": "user_id", - "name": , - "new": null, - "remove": , - }, - }, - ] - } - startCount={1} - term="asdfasdf" - total={2} - /> - +
+

+ Assigned People +

+
+ List of people assigned to this system role. +
+
+
+ +
+
+
+ +
+
+ Name +
+
+
+
+
+
+ + + + Loading +
+
+ +
+
+
`; exports[`admin_console/system_role_users should match snapshot with readOnly true 1`] = ` - +
+
- - - } - id="SystemRoleUsers" - subtitle={ - Object { - "defaultMessage": "List of people assigned to this system role.", - "id": "admin.permissions.system_role_users.description", - } - } - title={ - Object { - "defaultMessage": "Assigned People", - "id": "admin.permissions.system_role_users.title", - } - } -> - , - "width": 3, - }, - Object { - "field": "new", - "fixed": true, - "name": "", - "width": 1, - }, - Object { - "field": "remove", - "fixed": true, - "name": "", - "textAlign": "right", - }, - ] - } - endCount={2} - loading={true} - nextPage={[Function]} - onSearch={[Function]} - previousPage={[Function]} - rows={ - Array [ - Object { - "cells": Object { - "id": "user_id", - "name": , - "new": null, - "remove": , - }, - }, - Object { - "cells": Object { - "id": "user_id", - "name": , - "new": null, - "remove": , - }, - }, - ] - } - startCount={1} - term="asdfasdf" - total={2} - /> - +
+

+ Assigned People +

+
+ List of people assigned to this system role. +
+
+
+ +
+
+
+ +
+
+ Name +
+
+
+
+
+
+
+
+ + + user profile image + + +
+ + some-user - + + +
+
+
+
+
+ +
+
+
+
+
+ + + user profile image + + +
+ + some-user - + + +
+
+
+
+
+ +
+
+
+ +
+
+
`; diff --git a/webapp/channels/src/components/admin_console/system_roles/system_role/system_role_users/system_role_users.test.tsx b/webapp/channels/src/components/admin_console/system_roles/system_role/system_role_users/system_role_users.test.tsx index b70503aee48..f8651591a27 100644 --- a/webapp/channels/src/components/admin_console/system_roles/system_role/system_role_users/system_role_users.test.tsx +++ b/webapp/channels/src/components/admin_console/system_roles/system_role/system_role_users/system_role_users.test.tsx @@ -1,15 +1,16 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {shallow} from 'enzyme'; +import {screen, waitFor} from '@testing-library/react'; import React from 'react'; +import {renderWithContext} from 'tests/react_testing_utils'; import {TestHelper} from 'utils/test_helper'; import SystemRoleUsers from './system_role_users'; describe('admin_console/system_role_users', () => { - const props = { + const getBaseProps = () => ({ users: [TestHelper.getUserMock()], role: TestHelper.getRoleMock(), totalCount: 5, @@ -24,30 +25,43 @@ describe('admin_console/system_role_users', () => { onAddCallback: jest.fn(), onRemoveCallback: jest.fn(), actions: { - getFilteredUsersStats: jest.fn(), - getProfiles: jest.fn(), - searchProfiles: jest.fn(), + getFilteredUsersStats: jest.fn().mockResolvedValue({data: {}}), + getProfiles: jest.fn().mockResolvedValue({data: []}), + searchProfiles: jest.fn().mockResolvedValue({data: []}), setUserGridSearch: jest.fn(), }, readOnly: false, - }; - - test('should match snapshot', () => { - const wrapper = shallow( - ); - - expect(wrapper).toMatchSnapshot(); }); - test('should match snapshot with readOnly true', () => { - const wrapper = shallow( + test('should match snapshot', async () => { + const props = getBaseProps(); + const {container} = renderWithContext( + , + ); + + await waitFor(() => { + expect(props.actions.getProfiles).toHaveBeenCalledTimes(1); + }); + + expect(container).toMatchSnapshot(); + }); + + test('should match snapshot with readOnly true', async () => { + const props = getBaseProps(); + const {container} = renderWithContext( ); + />, + ); - expect(wrapper).toMatchSnapshot(); + await waitFor(() => { + expect(props.actions.getProfiles).toHaveBeenCalledTimes(1); + }); + + expect(screen.getByRole('button', {name: 'Add People'})).toBeDisabled(); + expect(container).toMatchSnapshot(); }); }); diff --git a/webapp/channels/src/components/admin_console/system_roles/system_roles.test.tsx b/webapp/channels/src/components/admin_console/system_roles/system_roles.test.tsx index 0120fd296d9..1cd1320fd23 100644 --- a/webapp/channels/src/components/admin_console/system_roles/system_roles.test.tsx +++ b/webapp/channels/src/components/admin_console/system_roles/system_roles.test.tsx @@ -1,9 +1,9 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {shallow} from 'enzyme'; import React from 'react'; +import {renderWithContext} from 'tests/react_testing_utils'; import {TestHelper} from 'utils/test_helper'; import SystemRoles from './system_roles'; @@ -18,11 +18,12 @@ describe('admin_console/system_roles', () => { }), }; - const wrapper = shallow( + const {container} = renderWithContext( ); + />, + ); - expect(wrapper).toMatchSnapshot(); + expect(container).toMatchSnapshot(); }); }); diff --git a/webapp/channels/src/components/admin_console/team_channel_settings/__snapshots__/abstract_list.test.tsx.snap b/webapp/channels/src/components/admin_console/team_channel_settings/__snapshots__/abstract_list.test.tsx.snap index a1b64e3bc25..2cce39f1803 100644 --- a/webapp/channels/src/components/admin_console/team_channel_settings/__snapshots__/abstract_list.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/team_channel_settings/__snapshots__/abstract_list.test.tsx.snap @@ -1,127 +1,146 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`admin_console/team_channel_settings/AbstractList should match snapshot, no headers 1`] = ` -
+
- +
+ test +
`; exports[`admin_console/team_channel_settings/AbstractList should match snapshot, with data 1`] = ` -
+
- -
-
- + Name
- + Team +
+
+ Management +
+
-
-
-
- -
-
- +
+
+ + DN + + + + +
+ +
+ + + Remove + + +
+
- - +
+ 1 - 1 of 1 +
+ + +
`; diff --git a/webapp/channels/src/components/admin_console/team_channel_settings/abstract_list.test.tsx b/webapp/channels/src/components/admin_console/team_channel_settings/abstract_list.test.tsx index 5ceef994b02..cae1dd13c01 100644 --- a/webapp/channels/src/components/admin_console/team_channel_settings/abstract_list.test.tsx +++ b/webapp/channels/src/components/admin_console/team_channel_settings/abstract_list.test.tsx @@ -1,12 +1,12 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {shallow} from 'enzyme'; import React from 'react'; import {FormattedMessage} from 'react-intl'; import type {Channel} from '@mattermost/types/channels'; +import {renderWithContext, waitFor} from 'tests/react_testing_utils'; import {TestHelper} from 'utils/test_helper'; import AbstractList from './abstract_list'; @@ -40,7 +40,7 @@ describe('admin_console/team_channel_settings/AbstractList', () => {
); - test('should match snapshot, no headers', () => { + test('should match snapshot, no headers', async () => { const testChannels: Channel[] = []; const actions = { @@ -49,7 +49,7 @@ describe('admin_console/team_channel_settings/AbstractList', () => { removeGroup: jest.fn(), }; - const wrapper = shallow( + const {container} = renderWithContext( { defaultMessage: 'test', }} actions={actions} - />); + />, + ); - wrapper.setState({loading: false}); - expect(wrapper).toMatchSnapshot(); + await waitFor(() => { + expect(actions.getData).toHaveBeenCalled(); + }); + + expect(container).toMatchSnapshot(); }); - test('should match snapshot, with data', () => { + test('should match snapshot, with data', async () => { const testTeams: TeamWithMembership[] = [TestHelper.getTeamMock({ id: '123', display_name: 'DN', @@ -78,7 +82,7 @@ describe('admin_console/team_channel_settings/AbstractList', () => { removeGroup: jest.fn(), }; - const wrapper = shallow( + const {container} = renderWithContext( { defaultMessage: 'test', }} actions={actions} - />); + />, + ); - wrapper.setState({loading: false}); - expect(wrapper).toMatchSnapshot(); + await waitFor(() => { + expect(actions.getData).toHaveBeenCalled(); + }); + + expect(container).toMatchSnapshot(); }); const renderRow = jest.fn((item) => { diff --git a/webapp/channels/src/components/admin_console/team_channel_settings/channel/__snapshots__/channel_settings.test.tsx.snap b/webapp/channels/src/components/admin_console/team_channel_settings/channel/__snapshots__/channel_settings.test.tsx.snap index 50819800474..d9441c7221f 100644 --- a/webapp/channels/src/components/admin_console/team_channel_settings/channel/__snapshots__/channel_settings.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/team_channel_settings/channel/__snapshots__/channel_settings.test.tsx.snap @@ -1,50 +1,44 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`admin_console/team_channel_settings/channel/ChannelSettings should match snapshot 1`] = ` -
- - - +
- +
+
- - +
+
+
+

+ Channels +

+
+ Manage channel settings. +
+
+
+
+ ChannelsList +
+
+
diff --git a/webapp/channels/src/components/admin_console/team_channel_settings/channel/channel_settings.test.tsx b/webapp/channels/src/components/admin_console/team_channel_settings/channel/channel_settings.test.tsx index 73e98d3f8e0..1d73d2655bd 100644 --- a/webapp/channels/src/components/admin_console/team_channel_settings/channel/channel_settings.test.tsx +++ b/webapp/channels/src/components/admin_console/team_channel_settings/channel/channel_settings.test.tsx @@ -1,18 +1,21 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {shallow} from 'enzyme'; import React from 'react'; +import {renderWithContext} from 'tests/react_testing_utils'; + import {ChannelsSettings} from './channel_settings'; +jest.mock('components/admin_console/team_channel_settings/channel/list', () => () =>
{'ChannelsList'}
); + describe('admin_console/team_channel_settings/channel/ChannelSettings', () => { test('should match snapshot', () => { - const wrapper = shallow( + const {container} = renderWithContext( , ); - expect(wrapper).toMatchSnapshot(); + expect(container).toMatchSnapshot(); }); }); diff --git a/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/__snapshots__/channel_details.test.tsx.snap b/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/__snapshots__/channel_details.test.tsx.snap index 4b2982e836c..a865bd20cf8 100644 --- a/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/__snapshots__/channel_details.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/__snapshots__/channel_details.test.tsx.snap @@ -1,1024 +1,1944 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`admin_console/team_channel_settings/channel/ChannelDetails should match snapshot 1`] = ` -
- -
- - -
-
+
- - - } - message={ - - } - onCancel={[Function]} - onConfirm={[Function]} - show={false} - title={ - - } - /> - - - - - - - - + + Channel Configuration +
+
+ `; exports[`admin_console/team_channel_settings/channel/ChannelDetails should match snapshot 2`] = ` -
- -
- - -
-
+
- - - } - message={ - - } - onCancel={[Function]} - onConfirm={[Function]} - show={false} - title={ - - } - /> - - - - - - - - + + Channel Configuration +
+
+ `; exports[`admin_console/team_channel_settings/channel/ChannelDetails should match snapshot for Enterprise 1`] = ` -
- -
- - -
-
+
- - - } - message={ - - } - onCancel={[Function]} - onConfirm={[Function]} - show={false} - title={ - - } - /> - - - - - - - + + Channel Configuration +
+
+
+
+
+
+
+

+ Channel Profile +

+
+ Summary of the channel, including the channel name. +
+
+
+
+
+
+ + Name + +
+ name +
+
+ + Team + +
+ test +
+
+ +
+
+
+
+
+
+
+

+ Advanced Access Control +

+
+ Manage the actions available to channel members and guests. +
+
+
+
+
+ + + + + + + + + +
+ Permissions + + Guests + + Members +
+
+
+
+
+
+
+

+ Channel Management +

+
+ Choose between inviting members manually or syncing members automatically from groups. +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ Select Public for a channel any user can find and join. +
+ Select Private to require channel invitations to join. +
+ Use this switch to change this channel from public to private or from private to public. +
+
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ Only private channels can be attribute based. +
+
+
+
+
+
+
+
+ ChannelMembers +
+
+
+
-
`; exports[`admin_console/team_channel_settings/channel/ChannelDetails should match snapshot for Enterprise 2`] = ` -
- -
- - -
-
+
- - - } - message={ - - } - onCancel={[Function]} - onConfirm={[Function]} - show={false} - title={ - - } - /> - - - - - - - + + Channel Configuration +
+
+
+
+
+
+
+

+ Channel Profile +

+
+ Summary of the channel, including the channel name. +
+
+
+
+
+
+ + Name + +
+ name +
+
+ + Team + +
+
+
+ +
+
+
+
+
+
+
+

+ Advanced Access Control +

+
+ Manage the actions available to channel members and guests. +
+
+
+
+
+ + + + + + + + + +
+ Permissions + + Guests + + Members +
+
+
+
+
+
+
+

+ Channel Management +

+
+ Choose between inviting members manually or syncing members automatically from groups. +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ Select Public for a channel any user can find and join. +
+ Select Private to require channel invitations to join. +
+ Use this switch to change this channel from public to private or from private to public. +
+
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ Only private channels can be attribute based. +
+
+
+
+
+
+
+
+ ChannelMembers +
+
+
+
-
`; exports[`admin_console/team_channel_settings/channel/ChannelDetails should match snapshot for Professional 1`] = ` -
- -
- - -
-
+
- - - } - message={ - - } - onCancel={[Function]} - onConfirm={[Function]} - show={false} - title={ - - } - /> - - - - - - - + + Channel Configuration +
+
+
+
+
+
+
+

+ Channel Profile +

+
+ Summary of the channel, including the channel name. +
+
+
+
+
+
+ + Name + +
+ name +
+
+ + Team + +
+ test +
+
+ +
+
+
+
+
+
+
+

+ Advanced Access Control +

+
+ Manage the actions available to channel members and guests. +
+
+
+
+
+ + + + + + + + + +
+ Permissions + + Guests + + Members +
+
+
+
+
+
+
+

+ Channel Management +

+
+ Choose between inviting members manually or syncing members automatically from groups. +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ Select Public for a channel any user can find and join. +
+ Select Private to require channel invitations to join. +
+ Use this switch to change this channel from public to private or from private to public. +
+
+
+
+
+
+
+
+
+
+
+ ChannelMembers +
+
+
+
-
`; exports[`admin_console/team_channel_settings/channel/ChannelDetails should match snapshot for Professional 2`] = ` -
- -
- - -
-
+
- - - } - message={ - - } - onCancel={[Function]} - onConfirm={[Function]} - show={false} - title={ - - } - /> - - - - - - - + + Channel Configuration +
+
+
+
+
+
+
+

+ Channel Profile +

+
+ Summary of the channel, including the channel name. +
+
+
+
+
+
+ + Name + +
+ name +
+
+ + Team + +
+
+
+ +
+
+
+
+
+
+
+

+ Advanced Access Control +

+
+ Manage the actions available to channel members and guests. +
+
+
+
+
+ + + + + + + + + +
+ Permissions + + Guests + + Members +
+
+
+
+
+
+
+

+ Channel Management +

+
+ Choose between inviting members manually or syncing members automatically from groups. +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ Select Public for a channel any user can find and join. +
+ Select Private to require channel invitations to join. +
+ Use this switch to change this channel from public to private or from private to public. +
+
+
+
+
+
+
+
+
+
+
+ ChannelMembers +
+
+
+
-
`; diff --git a/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/__snapshots__/channel_groups.test.tsx.snap b/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/__snapshots__/channel_groups.test.tsx.snap index 2a4b8e965d5..b36d87d3620 100644 --- a/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/__snapshots__/channel_groups.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/__snapshots__/channel_groups.test.tsx.snap @@ -1,88 +1,107 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`admin_console/team_channel_settings/channel/ChannelGroups should match snapshot 1`] = ` - +
+
- - - } - id="channel_groups" - subtitle={ - Object { - "defaultMessage": "Add and remove channel members based on their group membership.", - "id": "admin.channel_settings.channel_detail.syncedGroupsDescription", - } - } - title={ - Object { - "defaultMessage": "Synced Groups", - "id": "admin.channel_settings.channel_detail.syncedGroupsTitle", - } - } -> - - +
+

+ Synced Groups +

+
+ Add and remove channel members based on their group membership. +
+
+
+ +
+
+
+
+
+ Group Name +
+
+
+ Member Count +
+
+ Roles +
+
+
+
+
+
+ +
+
+ +
+
+
`; diff --git a/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/__snapshots__/channel_moderation.test.tsx.snap b/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/__snapshots__/channel_moderation.test.tsx.snap index ca1cf655e2d..a1ec3c8cdfc 100644 --- a/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/__snapshots__/channel_moderation.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/__snapshots__/channel_moderation.test.tsx.snap @@ -1,609 +1,1290 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`admin_console/team_channel_settings/channel/ChannelModeration Should match fifth Snapshot 1`] = ` - +
- +

+ Advanced Access Control +

+
+ Manage the actions available to channel members and guests. +
+ + +
+
-
- - - - - - - - - + + + + + + + + + + + + + + + -
- - - - - -
+ Permissions + + Guests + + Members +
+
+ Create Posts +
+
+ The ability for members and guests to create posts in the channel. +
+
+ + + +
+
+ Channel Mentions +
+
+ The ability for members and guests to use @all, @here and @channel. +
- -
, - ] - } - guestAccountsEnabled={true} - guests={false} - guestsDisabled={true} - key="use_channel_mentions" - members={false} - membersDisabled={true} - name="use_channel_mentions" - onClick={[Function]} - readOnly={false} - /> -
+ + Channel mentions for members and guests are disabled in + + dp Team Scheme + + . + +
+ + +
- +
`; exports[`admin_console/team_channel_settings/channel/ChannelModeration Should match first Snapshot 1`] = ` - +
- +

+ Advanced Access Control +

+
+ Manage the actions available to channel members and guests. +
+ + +
+
-
- - - - - - - - - -
- - - - - -
+ + + + + + + + + + + + + + + +
+ Permissions + + Guests + + Members +
+
+ Create Posts +
+
+ The ability for members and guests to create posts in the channel. +
+
+ + + +
+
-
+
`; exports[`admin_console/team_channel_settings/channel/ChannelModeration Should match fourth Snapshot 1`] = ` - +
- +

+ Advanced Access Control +

+
+ Manage the actions available to channel members and guests. +
+ + +
+
-
- - - - - - - - - + + + + + + + + + + + + + + + -
- - - - - -
+ Permissions + + Guests + + Members +
+
+ Create Posts +
+
+ The ability for members and guests to create posts in the channel. +
+
+ +
+
+ Channel Mentions +
+
+ The ability for members and guests to use @all, @here and @channel. +
- -
, - ] - } - guestAccountsEnabled={true} - guests={false} - guestsDisabled={true} - key="use_channel_mentions" - members={false} - membersDisabled={true} - name="use_channel_mentions" - onClick={[Function]} - readOnly={false} - /> -
+ Guests and members can not use channel mentions without the ability to create posts. +
+ + +
- +
`; exports[`admin_console/team_channel_settings/channel/ChannelModeration Should match second Snapshot 1`] = ` - - -
- -
-
- -
- - - - - - - - - +
+ + + + + + + + +
+
+ Create Posts +
+
+ The ability for members and guests to create posts in the channel. +
+
+ + + +
+
`; -exports[`admin_console/team_channel_settings/channel/ChannelModeration Should match seventh Snapshot 1`] = ` - - -
- -
-
- -
- - - - - - +exports[`admin_console/team_channel_settings/channel/ChannelModeration Should match snapshot for ChannelModerationTableRow with guest accounts disabled 1`] = ` +
+ + + + + + + +
+
+ Create Posts +
+
+ The ability for members to create posts in the channel. +
+
+ +
+
`; -exports[`admin_console/team_channel_settings/channel/ChannelModeration Should match sixth Snapshot 1`] = ` - +exports[`admin_console/team_channel_settings/channel/ChannelModeration Should match snapshot with create_post guests off and members on, private channel 1`] = ` +
- +

+ Advanced Access Control +

+
+ Manage the actions available to channel members and guests. +
+ + +
+
-
- - - - - - - - - + + + + + + + + + + + + + + + -
- - - - - -
+ Permissions + + Guests + + Members +
+
+ Create Posts +
+
+ The ability for members and guests to create posts in the channel. +
+
+ + +
+
+ Channel Mentions +
+
+ The ability for members and guests to use @all, @here and @channel. +
- -
, + Guests can not use channel mentions without the ability to create posts. +
- -
, - ] - } - guestAccountsEnabled={true} - guests={false} - guestsDisabled={true} - key="use_channel_mentions" - members={false} - membersDisabled={true} - name="use_channel_mentions" - onClick={[Function]} - readOnly={false} - /> -
+ + Channel mentions for members are disabled in + + dp Team Scheme + + . + +
+ + +
- +
`; -exports[`admin_console/team_channel_settings/channel/ChannelModeration Should match sixth Snapshot 2`] = ` - +exports[`admin_console/team_channel_settings/channel/ChannelModeration Should match snapshot with no team scheme and guest accounts disabled 1`] = ` +
- +

+ Advanced Access Control +

+
+ Manage the actions available to channel members. +
+ + +
+
-
- - - - - - - - -
- - - -
+ + + + + + + + + + + + + +
+ Permissions + + Members +
+
+ Create Posts +
+
+ The ability for members to create posts in the channel. +
+
+ +
+
-
+
`; exports[`admin_console/team_channel_settings/channel/ChannelModeration Should match third Snapshot 1`] = ` - +
- +

+ Advanced Access Control +

+
+ Manage the actions available to channel members and guests. +
+ + +
+
-
- - - - - - - - - + + + + + + + + + + + + + + + -
- - - - - -
+ Permissions + + Guests + + Members +
+
+ Create Posts +
+
+ The ability for members and guests to create posts in the channel. +
+
+ + +
+
+ Channel Mentions +
+
+ The ability for members and guests to use @all, @here and @channel. +
- -
, + Members can not use channel mentions without the ability to create posts. +
- -
, - ] - } - guestAccountsEnabled={true} - guests={false} - guestsDisabled={true} - key="use_channel_mentions" - members={false} - membersDisabled={true} - name="use_channel_mentions" - onClick={[Function]} - readOnly={false} - /> -
+ + Channel mentions for guests are disabled in + + dp Team Scheme + + . + +
+ + +
- +
`; diff --git a/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/__snapshots__/channel_modes.test.tsx.snap b/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/__snapshots__/channel_modes.test.tsx.snap index 6d8eb3043c6..f1a14f9d503 100644 --- a/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/__snapshots__/channel_modes.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/__snapshots__/channel_modes.test.tsx.snap @@ -1,82 +1,235 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`admin_console/team_channel_settings/channel/ChannelModes should match snapshot - not licensed for Group 1`] = ` - +
- +
+

+ Channel Management +

+
+ Choose between inviting members manually or syncing members automatically from groups. +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ Select Public for a channel any user can find and join. +
+ Select Private to require channel invitations to join. +
+ Use this switch to change this channel from public to private or from private to public. +
+
+
+
+
+
+
+
- +
`; exports[`admin_console/team_channel_settings/channel/ChannelModes should match snapshot 1`] = ` - +
- - +
+

+ Channel Management +

+
+ Choose between inviting members manually or syncing members automatically from groups. +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ 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. + + Learn More + +
+
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ Select Public for a channel any user can find and join. +
+ Select Private to require channel invitations to join. +
+ Use this switch to change this channel from public to private or from private to public. +
+
+
+
+
+
+
+
- +
`; diff --git a/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/__snapshots__/channel_profile.test.tsx.snap b/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/__snapshots__/channel_profile.test.tsx.snap index 45f7180ed21..b53ae4e3813 100644 --- a/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/__snapshots__/channel_profile.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/__snapshots__/channel_profile.test.tsx.snap @@ -1,153 +1,140 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`admin_console/team_channel_settings/channel/ChannelProfile should match snapshot 1`] = ` - +
+
+

+ Channel Profile +

+
+ Summary of the channel, including the channel name. +
+
+
+
- - - -
- test -
-
- - - -
- test -
-
- + + Name + +
+ test +
+
+ + Team + +
+ test +
+
+ +
-
+
`; exports[`admin_console/team_channel_settings/channel/ChannelProfile should match snapshot for a shared channel 1`] = ` - +
+
+

+ Channel Profile +

+
+ Summary of the channel, including the channel name. +
+
+
+
- - - -
- test -
-
- - - -
- test -
-
- - - -
- - -
-
-
+
+ + Team + +
+ test +
+
+ + Organizations + +
- - + Shared with trusted organizations +
+
+ +
-
+
`; diff --git a/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/channel_details.test.tsx b/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/channel_details.test.tsx index 6846e925f3b..c390943d6d7 100644 --- a/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/channel_details.test.tsx +++ b/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/channel_details.test.tsx @@ -1,116 +1,122 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {shallow} from 'enzyme'; import React from 'react'; import type {Channel} from '@mattermost/types/channels'; import type {Group} from '@mattermost/types/groups'; import type {Scheme} from '@mattermost/types/schemes'; +import {renderWithContext} from 'tests/react_testing_utils'; import {TestHelper} from 'utils/test_helper'; import ChannelDetails from './channel_details'; +jest.mock('utils/browser_history', () => ({ + getHistory: jest.fn(() => ({push: jest.fn(), listen: jest.fn()})), +})); + +jest.mock('./channel_members', () => () =>
{'ChannelMembers'}
); + describe('admin_console/team_channel_settings/channel/ChannelDetails', () => { + const groups: Group[] = [{ + id: '123', + name: 'name', + display_name: 'DN', + description: 'descript', + source: 'A', + remote_id: 'id', + create_at: 0, + update_at: 0, + delete_at: 0, + has_syncables: false, + member_count: 3, + scheme_admin: false, + allow_reference: false, + }]; + const allGroups = { + 123: groups[0], + }; + const testChannel: Channel & {team_name: string} = { + id: '123', + team_name: 'team', + create_at: 0, + update_at: 0, + delete_at: 0, + team_id: 'id_123', + type: 'O', + display_name: 'name', + name: 'DN', + header: 'header', + purpose: 'purpose', + last_post_at: 0, + last_root_post_at: 0, + creator_id: 'id', + scheme_id: 'id', + group_constrained: false, + }; + const team = TestHelper.getTeamMock({ + display_name: 'test', + }); + const teamScheme: Scheme = { + id: 'asdf', + name: 'asdf', + description: 'asdf', + display_name: 'asdf', + create_at: 0, + update_at: 0, + delete_at: 0, + scope: 'team', + default_team_admin_role: 'asdf', + default_team_user_role: 'asdf', + default_team_guest_role: 'asdf', + default_channel_admin_role: 'asdf', + default_channel_user_role: 'asdf', + default_channel_guest_role: 'asdf', + default_playbook_admin_role: 'asdf', + default_playbook_member_role: 'asdf', + default_run_member_role: 'asdf', + }; + + const actions = { + getChannel: jest.fn().mockResolvedValue([]), + getTeam: jest.fn().mockResolvedValue([]), + linkGroupSyncable: jest.fn(), + conver: jest.fn(), + patchChannel: jest.fn(), + setNavigationBlocked: jest.fn(), + unlinkGroupSyncable: jest.fn(), + getGroups: jest.fn().mockResolvedValue([]), + membersMinusGroupMembers: jest.fn(), + updateChannelPrivacy: jest.fn(), + patchGroupSyncable: jest.fn(), + getChannelModerations: jest.fn().mockResolvedValue([]), + patchChannelModerations: jest.fn(), + loadScheme: jest.fn(), + addChannelMember: jest.fn(), + removeChannelMember: jest.fn(), + updateChannelMemberSchemeRoles: jest.fn(), + deleteChannel: jest.fn(), + unarchiveChannel: jest.fn(), + getAccessControlPolicy: jest.fn().mockResolvedValue({data: null}), + deleteAccessControlPolicy: jest.fn(), + assignChannelToAccessControlPolicy: jest.fn(), + unassignChannelsFromAccessControlPolicy: jest.fn(), + searchPolicies: jest.fn(), + + // Channel-level access rules actions + getAccessControlFields: jest.fn().mockResolvedValue({data: []}), + getVisualAST: jest.fn().mockResolvedValue({data: {}}), + saveChannelAccessPolicy: jest.fn().mockResolvedValue({data: {}}), + validateChannelExpression: jest.fn().mockResolvedValue({data: {}}), + createAccessControlSyncJob: jest.fn().mockResolvedValue({data: {}}), + updateAccessControlPoliciesActive: jest.fn().mockResolvedValue({data: {}}), + searchUsersForExpression: jest.fn().mockResolvedValue({data: {users: [], total: 0}}), + getChannelMembers: jest.fn().mockResolvedValue({data: []}), + getProfilesByIds: jest.fn().mockResolvedValue({data: []}), + }; + test('should match snapshot', () => { - const groups: Group[] = [{ - id: '123', - name: 'name', - display_name: 'DN', - description: 'descript', - source: 'A', - remote_id: 'id', - create_at: 0, - update_at: 0, - delete_at: 0, - has_syncables: false, - member_count: 3, - scheme_admin: false, - allow_reference: false, - }]; - const allGroups = { - 123: groups[0], - }; - const testChannel: Channel & {team_name: string} = { - id: '123', - team_name: 'team', - create_at: 0, - update_at: 0, - delete_at: 0, - team_id: 'id_123', - type: 'O', - display_name: 'name', - name: 'DN', - header: 'header', - purpose: 'purpose', - last_post_at: 0, - last_root_post_at: 0, - creator_id: 'id', - scheme_id: 'id', - group_constrained: false, - }; - const team = TestHelper.getTeamMock({ - display_name: 'test', - }); - const teamScheme: Scheme = { - id: 'asdf', - name: 'asdf', - description: 'asdf', - display_name: 'asdf', - create_at: 0, - update_at: 0, - delete_at: 0, - scope: 'team', - default_team_admin_role: 'asdf', - default_team_user_role: 'asdf', - default_team_guest_role: 'asdf', - default_channel_admin_role: 'asdf', - default_channel_user_role: 'asdf', - default_channel_guest_role: 'asdf', - default_playbook_admin_role: 'asdf', - default_playbook_member_role: 'asdf', - default_run_member_role: 'asdf', - }; - - const actions = { - getChannel: jest.fn().mockResolvedValue([]), - getTeam: jest.fn().mockResolvedValue([]), - linkGroupSyncable: jest.fn(), - conver: jest.fn(), - patchChannel: jest.fn(), - setNavigationBlocked: jest.fn(), - unlinkGroupSyncable: jest.fn(), - getGroups: jest.fn().mockResolvedValue([]), - membersMinusGroupMembers: jest.fn(), - updateChannelPrivacy: jest.fn(), - patchGroupSyncable: jest.fn(), - getChannelModerations: jest.fn().mockResolvedValue([]), - patchChannelModerations: jest.fn(), - loadScheme: jest.fn(), - addChannelMember: jest.fn(), - removeChannelMember: jest.fn(), - updateChannelMemberSchemeRoles: jest.fn(), - deleteChannel: jest.fn(), - unarchiveChannel: jest.fn(), - getAccessControlPolicy: jest.fn().mockResolvedValue({data: null}), - deleteAccessControlPolicy: jest.fn(), - assignChannelToAccessControlPolicy: jest.fn(), - unassignChannelsFromAccessControlPolicy: jest.fn(), - searchPolicies: jest.fn(), - - // Channel-level access rules actions - getAccessControlFields: jest.fn().mockResolvedValue({data: []}), - getVisualAST: jest.fn().mockResolvedValue({data: {}}), - saveChannelAccessPolicy: jest.fn().mockResolvedValue({data: {}}), - validateChannelExpression: jest.fn().mockResolvedValue({data: {}}), - createAccessControlSyncJob: jest.fn().mockResolvedValue({data: {}}), - updateAccessControlPoliciesActive: jest.fn().mockResolvedValue({data: {}}), - searchUsersForExpression: jest.fn().mockResolvedValue({data: {users: [], total: 0}}), - getChannelMembers: jest.fn().mockResolvedValue({data: []}), - getProfilesByIds: jest.fn().mockResolvedValue({data: []}), - }; - const additionalProps = { channelPermissions: [], guestAccountsEnabled: true, @@ -120,11 +126,8 @@ describe('admin_console/team_channel_settings/channel/ChannelDetails', () => { isDisabled: false, }; - if (!testChannel.id) { - return; - } - - let wrapper = shallow( + let container; + ({container} = renderWithContext( { allGroups={allGroups} {...additionalProps} />, - ); - expect(wrapper).toMatchSnapshot(); + )); + expect(container).toMatchSnapshot(); - wrapper = shallow( + ({container} = renderWithContext( { allGroups={allGroups} {...additionalProps} />, - ); - expect(wrapper).toMatchSnapshot(); + )); + expect(container).toMatchSnapshot(); }); test('should match snapshot for Professional', () => { - const groups: Group[] = [{ - id: '123', - name: 'name', - display_name: 'DN', - description: 'descript', - source: 'A', - remote_id: 'id', - create_at: 0, - update_at: 0, - delete_at: 0, - has_syncables: false, - member_count: 3, - scheme_admin: false, - allow_reference: false, - }]; - const allGroups = { - 123: groups[0], - }; - const testChannel: Channel & {team_name: string} = { - id: '123', - team_name: 'team', - create_at: 0, - update_at: 0, - delete_at: 0, - team_id: 'id_123', - type: 'O', - display_name: 'name', - name: 'DN', - header: 'header', - purpose: 'purpose', - last_post_at: 0, - last_root_post_at: 0, - creator_id: 'id', - scheme_id: 'id', - group_constrained: false, - }; - const team = TestHelper.getTeamMock({ - display_name: 'test', - }); - const teamScheme: Scheme = { - id: 'asdf', - name: 'asdf', - description: 'asdf', - display_name: 'asdf', - create_at: 0, - update_at: 0, - delete_at: 0, - scope: 'team', - default_team_admin_role: 'asdf', - default_team_user_role: 'asdf', - default_team_guest_role: 'asdf', - default_channel_admin_role: 'asdf', - default_channel_user_role: 'asdf', - default_channel_guest_role: 'asdf', - default_playbook_admin_role: 'asdf', - default_playbook_member_role: 'asdf', - default_run_member_role: 'asdf', - }; - - const actions = { - getChannel: jest.fn().mockResolvedValue([]), - getTeam: jest.fn().mockResolvedValue([]), - linkGroupSyncable: jest.fn(), - conver: jest.fn(), - patchChannel: jest.fn(), - setNavigationBlocked: jest.fn(), - unlinkGroupSyncable: jest.fn(), - getGroups: jest.fn().mockResolvedValue([]), - membersMinusGroupMembers: jest.fn(), - updateChannelPrivacy: jest.fn(), - patchGroupSyncable: jest.fn(), - getChannelModerations: jest.fn().mockResolvedValue([]), - patchChannelModerations: jest.fn(), - loadScheme: jest.fn(), - addChannelMember: jest.fn(), - removeChannelMember: jest.fn(), - updateChannelMemberSchemeRoles: jest.fn(), - deleteChannel: jest.fn(), - unarchiveChannel: jest.fn(), - getAccessControlPolicy: jest.fn().mockResolvedValue({data: null}), - deleteAccessControlPolicy: jest.fn(), - assignChannelToAccessControlPolicy: jest.fn(), - unassignChannelsFromAccessControlPolicy: jest.fn(), - searchPolicies: jest.fn(), - - // Channel-level access rules actions - getAccessControlFields: jest.fn().mockResolvedValue({data: []}), - getVisualAST: jest.fn().mockResolvedValue({data: {}}), - saveChannelAccessPolicy: jest.fn().mockResolvedValue({data: {}}), - validateChannelExpression: jest.fn().mockResolvedValue({data: {}}), - createAccessControlSyncJob: jest.fn().mockResolvedValue({data: {}}), - updateAccessControlPoliciesActive: jest.fn().mockResolvedValue({data: {}}), - searchUsersForExpression: jest.fn().mockResolvedValue({data: {users: [], total: 0}}), - getChannelMembers: jest.fn().mockResolvedValue({data: []}), - getProfilesByIds: jest.fn().mockResolvedValue({data: []}), - }; - const additionalProps = { channelPermissions: [], guestAccountsEnabled: true, @@ -261,11 +167,8 @@ describe('admin_console/team_channel_settings/channel/ChannelDetails', () => { abacSupported: false, }; - if (!testChannel.id) { - return; - } - - let wrapper = shallow( + let container; + ({container} = renderWithContext( { allGroups={allGroups} {...additionalProps} />, - ); - expect(wrapper).toMatchSnapshot(); + )); + expect(container).toMatchSnapshot(); - wrapper = shallow( + ({container} = renderWithContext( { allGroups={allGroups} {...additionalProps} />, - ); - expect(wrapper).toMatchSnapshot(); + )); + expect(container).toMatchSnapshot(); }); test('should match snapshot for Enterprise', () => { - const groups: Group[] = [{ - id: '123', - name: 'name', - display_name: 'DN', - description: 'descript', - source: 'A', - remote_id: 'id', - create_at: 0, - update_at: 0, - delete_at: 0, - has_syncables: false, - member_count: 3, - scheme_admin: false, - allow_reference: false, - }]; - const allGroups = { - 123: groups[0], - }; - const testChannel: Channel & {team_name: string} = { - id: '123', - team_name: 'team', - create_at: 0, - update_at: 0, - delete_at: 0, - team_id: 'id_123', - type: 'O', - display_name: 'name', - name: 'DN', - header: 'header', - purpose: 'purpose', - last_post_at: 0, - last_root_post_at: 0, - creator_id: 'id', - scheme_id: 'id', - group_constrained: false, - }; - const team = TestHelper.getTeamMock({ - display_name: 'test', - }); - const teamScheme: Scheme = { - id: 'asdf', - name: 'asdf', - description: 'asdf', - display_name: 'asdf', - create_at: 0, - update_at: 0, - delete_at: 0, - scope: 'team', - default_team_admin_role: 'asdf', - default_team_user_role: 'asdf', - default_team_guest_role: 'asdf', - default_channel_admin_role: 'asdf', - default_channel_user_role: 'asdf', - default_channel_guest_role: 'asdf', - default_playbook_admin_role: 'asdf', - default_playbook_member_role: 'asdf', - default_run_member_role: 'asdf', - }; - - const actions = { - getChannel: jest.fn().mockResolvedValue([]), - getTeam: jest.fn().mockResolvedValue([]), - linkGroupSyncable: jest.fn(), - conver: jest.fn(), - patchChannel: jest.fn(), - setNavigationBlocked: jest.fn(), - unlinkGroupSyncable: jest.fn(), - getGroups: jest.fn().mockResolvedValue([]), - membersMinusGroupMembers: jest.fn(), - updateChannelPrivacy: jest.fn(), - patchGroupSyncable: jest.fn(), - getChannelModerations: jest.fn().mockResolvedValue([]), - patchChannelModerations: jest.fn(), - loadScheme: jest.fn(), - addChannelMember: jest.fn(), - removeChannelMember: jest.fn(), - updateChannelMemberSchemeRoles: jest.fn(), - deleteChannel: jest.fn(), - unarchiveChannel: jest.fn(), - getAccessControlPolicy: jest.fn().mockResolvedValue({data: null}), - deleteAccessControlPolicy: jest.fn(), - assignChannelToAccessControlPolicy: jest.fn(), - unassignChannelsFromAccessControlPolicy: jest.fn(), - searchPolicies: jest.fn(), - - // Channel-level access rules actions - getAccessControlFields: jest.fn().mockResolvedValue({data: []}), - getVisualAST: jest.fn().mockResolvedValue({data: {}}), - saveChannelAccessPolicy: jest.fn().mockResolvedValue({data: {}}), - validateChannelExpression: jest.fn().mockResolvedValue({data: {}}), - createAccessControlSyncJob: jest.fn().mockResolvedValue({data: {}}), - updateAccessControlPoliciesActive: jest.fn().mockResolvedValue({data: {}}), - searchUsersForExpression: jest.fn().mockResolvedValue({data: {users: [], total: 0}}), - getChannelMembers: jest.fn().mockResolvedValue({data: []}), - getProfilesByIds: jest.fn().mockResolvedValue({data: []}), - }; - const additionalProps = { channelPermissions: [], guestAccountsEnabled: true, @@ -403,11 +209,8 @@ describe('admin_console/team_channel_settings/channel/ChannelDetails', () => { abacSupported: true, }; - if (!testChannel.id) { - return; - } - - let wrapper = shallow( + let container; + ({container} = renderWithContext( { allGroups={allGroups} {...additionalProps} />, - ); - expect(wrapper).toMatchSnapshot(); + )); + expect(container).toMatchSnapshot(); - wrapper = shallow( + ({container} = renderWithContext( { allGroups={allGroups} {...additionalProps} />, - ); - expect(wrapper).toMatchSnapshot(); + )); + expect(container).toMatchSnapshot(); }); }); diff --git a/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/channel_groups.test.tsx b/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/channel_groups.test.tsx index 361726eac15..67b36038c1e 100644 --- a/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/channel_groups.test.tsx +++ b/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/channel_groups.test.tsx @@ -1,12 +1,13 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {shallow} from 'enzyme'; import React from 'react'; import type {Channel} from '@mattermost/types/channels'; import type {Group} from '@mattermost/types/groups'; +import {renderWithContext} from 'tests/react_testing_utils'; + import {ChannelGroups} from './channel_groups'; describe('admin_console/team_channel_settings/channel/ChannelGroups', () => { @@ -24,7 +25,7 @@ describe('admin_console/team_channel_settings/channel/ChannelGroups', () => { group_constrained: false, name: 'DN', }; - const wrapper = shallow( + const {container} = renderWithContext( { isDisabled={false} />, ); - expect(wrapper).toMatchSnapshot(); + expect(container).toMatchSnapshot(); }); }); diff --git a/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/channel_members/__snapshots__/channel_members.test.tsx.snap b/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/channel_members/__snapshots__/channel_members.test.tsx.snap index 100189ce385..136656c4446 100644 --- a/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/channel_members/__snapshots__/channel_members.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/team_channel_settings/channel/details/channel_members/__snapshots__/channel_members.test.tsx.snap @@ -1,454 +1,466 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`admin_console/team_channel_settings/channel/ChannelMembers should match snapshot 1`] = ` - +
+
- - - } - id="channelMembers" - subtitle={ - Object { - "defaultMessage": "A list of users who are currently in the channel right now", - "id": "admin.channel_settings.channel_detail.membersDescription", - } - } - title={ - Object { - "defaultMessage": "Members", - "id": "admin.channel_settings.channel_detail.membersTitle", - } - } -> - , - "values": Object { - "channel_admin": Object { - "name": , - "value": false, - }, - "channel_user": Object { - "name": , - "value": false, - }, - "system_admin": Object { - "name": , - "value": false, - }, - "system_guest": Object { - "name": , - "value": false, - }, - }, - }, - }, - } - } - includeUsers={Object {}} - loadPage={[Function]} - loading={true} - memberships={ - Object { - "user-1": Object { - "channel_id": "channel_id", - "last_update_at": 0, - "last_viewed_at": 0, - "mention_count": 0, - "mention_count_root": 0, - "msg_count": 0, - "msg_count_root": 0, - "notify_props": Object { - "channel_auto_follow_threads": "off", - "desktop": "default", - "email": "default", - "ignore_channel_mentions": "default", - "mark_unread": "all", - "push": "default", - }, - "roles": "channel_user", - "scheme_admin": false, - "scheme_user": true, - "urgent_mention_count": 0, - "user_id": "user-1", - }, - "user-2": Object { - "channel_id": "channel_id", - "last_update_at": 0, - "last_viewed_at": 0, - "mention_count": 0, - "mention_count_root": 0, - "msg_count": 0, - "msg_count_root": 0, - "notify_props": Object { - "channel_auto_follow_threads": "off", - "desktop": "default", - "email": "default", - "ignore_channel_mentions": "default", - "mark_unread": "all", - "push": "default", - }, - "roles": "channel_user", - "scheme_admin": false, - "scheme_user": true, - "urgent_mention_count": 0, - "user_id": "user-2", - }, - "user-3": Object { - "channel_id": "channel_id", - "last_update_at": 0, - "last_viewed_at": 0, - "mention_count": 0, - "mention_count_root": 0, - "msg_count": 0, - "msg_count_root": 0, - "notify_props": Object { - "channel_auto_follow_threads": "off", - "desktop": "default", - "email": "default", - "ignore_channel_mentions": "default", - "mark_unread": "all", - "push": "default", - }, - "roles": "channel_user", - "scheme_admin": false, - "scheme_user": true, - "urgent_mention_count": 0, - "user_id": "user-3", - }, - } - } - onSearch={[Function]} - removeUser={[Function]} - scope="channel" - term="" - totalCount={3} - updateMembership={[Function]} - users={ - Array [ - Object { - "auth_service": "", - "bot_description": "", - "create_at": 0, - "delete_at": 0, - "email": "", - "first_name": "", - "id": "user-1", - "is_bot": false, - "last_activity_at": 0, - "last_name": "", - "last_password_update": 0, - "last_picture_update": 0, - "locale": "", - "mfa_active": false, - "nickname": "", - "notify_props": Object { - "calls_desktop_sound": "true", - "channel": "false", - "comments": "never", - "desktop": "default", - "desktop_sound": "false", - "email": "false", - "first_name": "false", - "highlight_keys": "", - "mark_unread": "mention", - "mention_keys": "", - "push": "none", - "push_status": "offline", - }, - "password": "", - "position": "", - "props": Object {}, - "roles": "", - "terms_of_service_create_at": 0, - "terms_of_service_id": "", - "update_at": 0, - "username": "some-user", - }, - Object { - "auth_service": "", - "bot_description": "", - "create_at": 0, - "delete_at": 0, - "email": "", - "first_name": "", - "id": "user-2", - "is_bot": false, - "last_activity_at": 0, - "last_name": "", - "last_password_update": 0, - "last_picture_update": 0, - "locale": "", - "mfa_active": false, - "nickname": "", - "notify_props": Object { - "calls_desktop_sound": "true", - "channel": "false", - "comments": "never", - "desktop": "default", - "desktop_sound": "false", - "email": "false", - "first_name": "false", - "highlight_keys": "", - "mark_unread": "mention", - "mention_keys": "", - "push": "none", - "push_status": "offline", - }, - "password": "", - "position": "", - "props": Object {}, - "roles": "", - "terms_of_service_create_at": 0, - "terms_of_service_id": "", - "update_at": 0, - "username": "some-user", - }, - Object { - "auth_service": "", - "bot_description": "", - "create_at": 0, - "delete_at": 0, - "email": "", - "first_name": "", - "id": "user-3", - "is_bot": false, - "last_activity_at": 0, - "last_name": "", - "last_password_update": 0, - "last_picture_update": 0, - "locale": "", - "mfa_active": false, - "nickname": "", - "notify_props": Object { - "calls_desktop_sound": "true", - "channel": "false", - "comments": "never", - "desktop": "default", - "desktop_sound": "false", - "email": "false", - "first_name": "false", - "highlight_keys": "", - "mark_unread": "mention", - "mention_keys": "", - "push": "none", - "push_status": "offline", - }, - "password": "", - "position": "", - "props": Object {}, - "roles": "", - "terms_of_service_create_at": 0, - "terms_of_service_id": "", - "update_at": 0, - "username": "some-user", - }, - ] - } - /> - +
+

+ Members +

+
+ A list of users who are currently in the channel right now +
+
+
+ +
+
+
+