diff --git a/webapp/channels/src/components/drafts/panel/__snapshots__/panel_body.test.tsx.snap b/webapp/channels/src/components/drafts/panel/__snapshots__/panel_body.test.tsx.snap index c53c3c4549..cfde375735 100644 --- a/webapp/channels/src/components/drafts/panel/__snapshots__/panel_body.test.tsx.snap +++ b/webapp/channels/src/components/drafts/panel/__snapshots__/panel_body.test.tsx.snap @@ -643,6 +643,7 @@ exports[`components/drafts/panel/panel_body should match snapshot for priority 1 size="xs" >
{ expect(screen.queryByTestId('fileAttachmentList')).not.toBeInTheDocument(); }); }); + + describe('priority labels', () => { + test('should show priority label for non-deleted post with priority metadata', () => { + const post = TestHelper.getPostMock({ + metadata: { + priority: { + priority: PostPriority.URGENT, + }, + }, + }); + const props = { + ...baseProps, + post, + isPostPriorityEnabled: true, + }; + renderWithContext(); + + expect(screen.getByTestId('post-priority-label')).toBeInTheDocument(); + }); + + test('should show priority label for non-deleted post with important priority metadata', () => { + const post = TestHelper.getPostMock({ + metadata: { + priority: { + priority: PostPriority.IMPORTANT, + }, + }, + }); + const props = { + ...baseProps, + post, + isPostPriorityEnabled: true, + }; + renderWithContext(); + + expect(screen.getByTestId('post-priority-label')).toBeInTheDocument(); + }); + + test('should not show priority label for deleted post with priority metadata', () => { + const post = TestHelper.getPostMock({ + state: Posts.POST_DELETED as 'DELETED', + metadata: { + priority: { + priority: PostPriority.URGENT, + }, + }, + }); + const props = { + ...baseProps, + post, + isPostPriorityEnabled: true, + }; + renderWithContext(); + + expect(screen.queryByTestId('post-priority-label')).not.toBeInTheDocument(); + }); + + test('should not show priority label for deleted post with important priority metadata', () => { + const post = TestHelper.getPostMock({ + state: Posts.POST_DELETED as 'DELETED', + metadata: { + priority: { + priority: PostPriority.IMPORTANT, + }, + }, + }); + const props = { + ...baseProps, + post, + isPostPriorityEnabled: true, + }; + renderWithContext(); + + expect(screen.queryByTestId('post-priority-label')).not.toBeInTheDocument(); + }); + + test('should not show priority label for post without priority metadata', () => { + const post = TestHelper.getPostMock(); + const props = { + ...baseProps, + post, + isPostPriorityEnabled: true, + }; + renderWithContext(); + + expect(screen.queryByTestId('post-priority-label')).not.toBeInTheDocument(); + }); + }); }); diff --git a/webapp/channels/src/components/post/post_component.tsx b/webapp/channels/src/components/post/post_component.tsx index 867c7c6e55..15277ed73d 100644 --- a/webapp/channels/src/components/post/post_component.tsx +++ b/webapp/channels/src/components/post/post_component.tsx @@ -505,7 +505,7 @@ function PostComponent(props: Props) { }; let priority; - if (post.metadata?.priority && props.isPostPriorityEnabled) { + if (post.metadata?.priority && props.isPostPriorityEnabled && post.state !== Posts.POST_DELETED) { priority = ; } diff --git a/webapp/channels/src/components/post_priority/post_priority_label.tsx b/webapp/channels/src/components/post_priority/post_priority_label.tsx index 04705db997..c815e266b3 100644 --- a/webapp/channels/src/components/post_priority/post_priority_label.tsx +++ b/webapp/channels/src/components/post_priority/post_priority_label.tsx @@ -29,6 +29,7 @@ export default function PriorityLabel({ icon={'alert-outline'} text={formatMessage({id: 'post_priority.priority.urgent', defaultMessage: 'Urgent'})} uppercase={true} + data-testid='post-priority-label' /> ); } @@ -41,6 +42,7 @@ export default function PriorityLabel({ icon={'alert-circle-outline'} text={formatMessage({id: 'post_priority.priority.important', defaultMessage: 'Important'})} uppercase={true} + data-testid='post-priority-label' /> ); }