diff --git a/webapp/channels/src/components/admin_console/permission_schemes_settings/__snapshots__/permission_description.test.tsx.snap b/webapp/channels/src/components/admin_console/permission_schemes_settings/__snapshots__/permission_description.test.tsx.snap new file mode 100644 index 0000000000..e42e6add63 --- /dev/null +++ b/webapp/channels/src/components/admin_console/permission_schemes_settings/__snapshots__/permission_description.test.tsx.snap @@ -0,0 +1,167 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`components/admin_console/permission_schemes_settings/permission_description should allow select with link 1`] = ` + + + + + + + Inherited from + + All Members + + . + + + + + + + + + +`; + +exports[`components/admin_console/permission_schemes_settings/permission_description should match snapshot if inherited 1`] = ` + + + +`; + +exports[`components/admin_console/permission_schemes_settings/permission_description should match snapshot with clickable link 1`] = ` + + + This is a clickable description + + + + + This is a clickable description + + + + +`; + +exports[`components/admin_console/permission_schemes_settings/permission_description should match snapshot with default Props 1`] = ` + + This is the description + + + This is the description + + + +`; diff --git a/webapp/channels/src/components/admin_console/permission_schemes_settings/__snapshots__/permission_group.test.tsx.snap b/webapp/channels/src/components/admin_console/permission_schemes_settings/__snapshots__/permission_group.test.tsx.snap index ec861441aa..5d8309d7b7 100644 --- a/webapp/channels/src/components/admin_console/permission_schemes_settings/__snapshots__/permission_group.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/permission_schemes_settings/__snapshots__/permission_group.test.tsx.snap @@ -668,3 +668,56 @@ exports[`components/admin_console/permission_schemes_settings/permission_group s `; + +exports[`components/admin_console/permission_schemes_settings/permission_group should match snapshot with additional values 1`] = ` +
+
+
+ + + name + + +
+
+ + +
+
+`; diff --git a/webapp/channels/src/components/admin_console/permission_schemes_settings/__snapshots__/permission_row.test.tsx.snap b/webapp/channels/src/components/admin_console/permission_schemes_settings/__snapshots__/permission_row.test.tsx.snap index 5f043e4859..8960c89bfc 100644 --- a/webapp/channels/src/components/admin_console/permission_schemes_settings/__snapshots__/permission_row.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/permission_schemes_settings/__snapshots__/permission_row.test.tsx.snap @@ -100,3 +100,40 @@ exports[`components/admin_console/permission_schemes_settings/permission_row sho />
`; + +exports[`components/admin_console/permission_schemes_settings/permission_row should match snapshot with additional values 1`] = ` +
+ + + id + + , + }, + } + } + description="" + id="id" + selectRow={[MockFunction]} + /> +
+`; diff --git a/webapp/channels/src/components/admin_console/permission_schemes_settings/permission_description.test.tsx b/webapp/channels/src/components/admin_console/permission_schemes_settings/permission_description.test.tsx new file mode 100644 index 0000000000..30cc15fbca --- /dev/null +++ b/webapp/channels/src/components/admin_console/permission_schemes_settings/permission_description.test.tsx @@ -0,0 +1,90 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import {shallow} from 'enzyme'; +import React from 'react'; +import * as reactRedux from 'react-redux'; + +import {mountWithIntl} from 'tests/helpers/intl-test-helper'; +import mockStore from 'tests/test_store'; + +import PermissionDescription from './permission_description'; + +describe('components/admin_console/permission_schemes_settings/permission_description', () => { + const defaultProps = { + id: 'defaultID', + selectRow: jest.fn(), + description: 'This is the description', + }; + + let store = mockStore(); + beforeEach(() => { + const initialState = { + entities: { + general: { + config: {}, + }, + users: { + currentUserId: 'currentUserId', + }, + }, + }; + store = mockStore(initialState); + }); + + test('should match snapshot with default Props', () => { + const wrapper = shallow( + , + ); + expect(wrapper).toMatchSnapshot(); + }); + + test('should match snapshot if inherited', () => { + const wrapper = shallow( + + + , + ); + expect(wrapper).toMatchSnapshot(); + }); + + test('should match snapshot with clickable link', () => { + const description = ( + {'This is a clickable description'} + ); + const wrapper = shallow( + , + ); + expect(wrapper).toMatchSnapshot(); + }); + + test('should allow select with link', () => { + const selectRow = jest.fn(); + + const wrapper = mountWithIntl( + + + , + ); + expect(wrapper).toMatchSnapshot(); + + wrapper.find('a').simulate('click'); + expect(selectRow).toBeCalled(); + }); +}); diff --git a/webapp/channels/src/components/admin_console/permission_schemes_settings/permission_description.tsx b/webapp/channels/src/components/admin_console/permission_schemes_settings/permission_description.tsx index c8b6ecaed5..c6f6085d62 100644 --- a/webapp/channels/src/components/admin_console/permission_schemes_settings/permission_description.tsx +++ b/webapp/channels/src/components/admin_console/permission_schemes_settings/permission_description.tsx @@ -4,15 +4,12 @@ import React, {useState, useRef} from 'react'; import type {MouseEvent} from 'react'; import {Overlay} from 'react-bootstrap'; -import {useIntl} from 'react-intl'; +import {FormattedMessage, useIntl} from 'react-intl'; import type {Role} from '@mattermost/types/roles'; -import FormattedMarkdownMessage from 'components/formatted_markdown_message'; import Tooltip from 'components/tooltip'; -import {generateId} from 'utils/utils'; - import type {AdditionalValues} from './permissions_tree/types'; import {rolesRolesStrings} from './strings/roles'; @@ -32,7 +29,6 @@ const PermissionDescription = ({ inherited, }: Props): JSX.Element => { const [open, setOpen] = useState(false); - const randomId = generateId(); const contentRef = useRef(null); const intl = useIntl(); @@ -57,12 +53,18 @@ const PermissionDescription = ({ let content: string | JSX.Element = ''; if (inherited && inherited.name) { + const formattedName = intl.formatMessage(rolesRolesStrings[inherited.name]); content = ( - ( + {text} + ), + }} /> ); @@ -75,7 +77,7 @@ const PermissionDescription = ({ placement='top' target={(contentRef.current as HTMLSpanElement)} > - + {content} diff --git a/webapp/channels/src/components/admin_console/permission_schemes_settings/permission_group.test.tsx b/webapp/channels/src/components/admin_console/permission_schemes_settings/permission_group.test.tsx index a32393ebc9..712b0e35fd 100644 --- a/webapp/channels/src/components/admin_console/permission_schemes_settings/permission_group.test.tsx +++ b/webapp/channels/src/components/admin_console/permission_schemes_settings/permission_group.test.tsx @@ -3,6 +3,7 @@ import {shallow} from 'enzyme'; import React from 'react'; +import {Button} from 'react-bootstrap'; import PermissionGroup from 'components/admin_console/permission_schemes_settings/permission_group'; @@ -111,6 +112,26 @@ describe('components/admin_console/permission_schemes_settings/permission_group' expect(wrapper).toMatchSnapshot(); }); + test('should match snapshot with additional values', () => { + const ADDITIONAL_VALUES = { + edit_post: { + editTimeLimitButton: ( +