- {value} -
+ {(attribute.type === 'multiselect' || attribute.type === 'select') && ( ++ {displayValue} +
+ ); +}; + +export default ProfilePopoverSelectAttribute; diff --git a/webapp/channels/src/components/profile_popover/profile_popover_text_attribute.test.tsx b/webapp/channels/src/components/profile_popover/profile_popover_text_attribute.test.tsx new file mode 100644 index 0000000000..66d5f2f0da --- /dev/null +++ b/webapp/channels/src/components/profile_popover/profile_popover_text_attribute.test.tsx @@ -0,0 +1,75 @@ +// 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 type {UserPropertyField} from '@mattermost/types/properties'; + +import {renderWithContext} from 'tests/react_testing_utils'; + +import ProfilePopoverTextAttribute from './profile_popover_text_attribute'; + +import {TestHelper} from '../../utils/test_helper'; + +describe('components/ProfilePopoverTextAttribute', () => { + const attribute: UserPropertyField = { + id: 'text_attribute_id', + name: 'Text Attribute', + type: 'text', + group_id: 'custom_profile_attributes', + create_at: 0, + update_at: 0, + delete_at: 0, + attrs: { + value_type: 'phone', + visibility: 'when_set', + sort_order: 0, + }, + }; + + const baseProps = { + attribute, + userProfile: TestHelper.getUserMock({ + id: 'user_id', + custom_profile_attributes: { + text_attribute_id: 'text value', + }, + }), + }; + + test('should render text attribute value', () => { + renderWithContext(+ {attributeValue} +
+ ); +}; + +export default ProfilePopoverTextAttribute; diff --git a/webapp/channels/src/components/profile_popover/profile_popover_url.test.tsx b/webapp/channels/src/components/profile_popover/profile_popover_url.test.tsx new file mode 100644 index 0000000000..cf1fa315ff --- /dev/null +++ b/webapp/channels/src/components/profile_popover/profile_popover_url.test.tsx @@ -0,0 +1,94 @@ +// 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 type {UserPropertyField} from '@mattermost/types/properties'; + +import {renderWithContext} from 'tests/react_testing_utils'; + +import ProfilePopoverUrl from './profile_popover_url'; + +import {TestHelper} from '../../utils/test_helper'; + +describe('components/ProfilePopoverUrl', () => { + const attribute: UserPropertyField = { + id: 'url_attribute_id', + name: 'Website', + type: 'text', + group_id: 'custom_profile_attributes', + create_at: 0, + update_at: 0, + delete_at: 0, + attrs: { + value_type: 'url', + visibility: 'when_set', + sort_order: 0, + }, + }; + + const baseProps = { + attribute, + userProfile: TestHelper.getUserMock({ + id: 'user_id', + custom_profile_attributes: { + url_attribute_id: 'https://example.com', + }, + }), + }; + + test('should not render when url is missing', () => { + const props = { + ...baseProps, + userProfile: TestHelper.getUserMock({ + id: 'user_id', + custom_profile_attributes: {}, + }), + }; + renderWithContext(