* Show profile message actions for non-DM user profiles
* Add DM profile visibility safeguards and coverage
* Simplify DM channel name parsing and add reversed order test
Remove redundant manual split('__') validation in
isDirectMessageWithViewedUser, relying on getUserIdFromChannelName
which already handles both name orderings. Add test for reversed
DM channel name order (B__A) to prevent regressions.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {shouldShowUserProfileOptions} from './user_profile';
|
|
|
|
describe('screens/user_profile/user_profile', () => {
|
|
it('should hide profile options when viewing the same user in a DM from channel context', () => {
|
|
const shouldShow = shouldShowUserProfileOptions({
|
|
channelContext: true,
|
|
isDirectMessageWithUser: true,
|
|
manageMode: false,
|
|
override: false,
|
|
});
|
|
|
|
expect(shouldShow).toBe(false);
|
|
});
|
|
|
|
it('should show profile options when viewing another user in a DM from channel context', () => {
|
|
const shouldShow = shouldShowUserProfileOptions({
|
|
channelContext: true,
|
|
isDirectMessageWithUser: false,
|
|
manageMode: false,
|
|
override: false,
|
|
});
|
|
|
|
expect(shouldShow).toBe(true);
|
|
});
|
|
|
|
it('should hide profile options when in manage mode', () => {
|
|
const shouldShow = shouldShowUserProfileOptions({
|
|
channelContext: true,
|
|
isDirectMessageWithUser: false,
|
|
manageMode: true,
|
|
override: false,
|
|
});
|
|
|
|
expect(shouldShow).toBe(false);
|
|
});
|
|
|
|
it('should hide profile options when override is enabled', () => {
|
|
const shouldShow = shouldShowUserProfileOptions({
|
|
channelContext: false,
|
|
isDirectMessageWithUser: false,
|
|
manageMode: false,
|
|
override: true,
|
|
});
|
|
|
|
expect(shouldShow).toBe(false);
|
|
});
|
|
|
|
it('should show profile options outside channel context even for direct message with viewed user', () => {
|
|
const shouldShow = shouldShowUserProfileOptions({
|
|
channelContext: false,
|
|
isDirectMessageWithUser: true,
|
|
manageMode: false,
|
|
override: false,
|
|
});
|
|
|
|
expect(shouldShow).toBe(true);
|
|
});
|
|
});
|