* fixes MM-37294 MM-37296 MM-37297 * Added conditions to check for post & thread existence * Update app/mm-redux/selectors/entities/threads.ts Co-authored-by: Kyriakos Z. <3829551+koox00@users.noreply.github.com> * type fix * Never disabling Mark All as unread * Added follow/unfollow message for not yet thread posts * Test case fix for mark all as unread enabled all the time * Removed hardcoded condition * Fixed MM-37509 * Updated snapshot for sidebar * Global thread actions init * Added options * Update post_options.js * Test cases fix * Added border bottom for each thread option * Update test case * Reverting snapshot * Updated snapshot * Moved options to screens & removed redundants translations * Reusing post_option for thread_option * Component name changed to PostOption from ThreadOption * Snapshot updated * Removed factory * Update app/screens/thread_options/index.ts Co-authored-by: Elias Nahum <nahumhbl@gmail.com> * Update app/screens/thread_options/index.ts Co-authored-by: Elias Nahum <nahumhbl@gmail.com> Co-authored-by: Kyriakos Z. <3829551+koox00@users.noreply.github.com> Co-authored-by: Mattermod <mattermod@users.noreply.github.com> Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
81 lines
2.3 KiB
TypeScript
81 lines
2.3 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {shallow} from 'enzyme';
|
|
import React from 'react';
|
|
|
|
import Preferences from '@mm-redux/constants/preferences';
|
|
import {intl} from '@test/intl-test-helper';
|
|
|
|
import {ThreadOptions} from './thread_options';
|
|
|
|
import type {Post} from '@mm-redux/types/posts';
|
|
import type {UserThread} from '@mm-redux/types/threads';
|
|
|
|
describe('ThreadOptions', () => {
|
|
const actions = {
|
|
flagPost: jest.fn(),
|
|
setThreadFollow: jest.fn(),
|
|
setUnreadPost: jest.fn(),
|
|
showPermalink: jest.fn(),
|
|
unflagPost: jest.fn(),
|
|
updateThreadRead: jest.fn(),
|
|
};
|
|
|
|
const post = {
|
|
id: 'post_id',
|
|
message: 'message',
|
|
is_pinned: false,
|
|
channel_id: 'channel_id',
|
|
} as Post;
|
|
|
|
const thread = {
|
|
id: 'post_id',
|
|
unread_replies: 4,
|
|
} as UserThread;
|
|
|
|
const baseProps = {
|
|
actions,
|
|
currentTeamName: 'current team name',
|
|
currentTeamUrl: 'http://localhost:8065/team-name',
|
|
currentUserId: 'user1',
|
|
deviceHeight: 600,
|
|
isFlagged: true,
|
|
intl,
|
|
post,
|
|
rootId: 'post_id',
|
|
theme: Preferences.THEMES.denim,
|
|
thread,
|
|
};
|
|
|
|
function getWrapper(props = {}) {
|
|
return shallow(
|
|
<ThreadOptions
|
|
{...baseProps}
|
|
{...props}
|
|
/>,
|
|
);
|
|
}
|
|
|
|
test('should match snapshot, showing all possible options', () => {
|
|
const wrapper = getWrapper();
|
|
expect(wrapper.getElement()).toMatchSnapshot();
|
|
expect(wrapper.findWhere((node) => node.key() === 'flagged')).toMatchObject({});
|
|
expect(wrapper.findWhere((node) => node.key() === 'mark_as_read')).toMatchObject({});
|
|
});
|
|
|
|
test('should show unflag option', () => {
|
|
const wrapper = getWrapper({isFlagged: false});
|
|
expect(wrapper.findWhere((node) => node.key() === 'unflag')).toMatchObject({});
|
|
});
|
|
|
|
test('should show unflag option', () => {
|
|
const wrapper = getWrapper({
|
|
thread: {
|
|
...thread,
|
|
unread_replies: 0,
|
|
},
|
|
});
|
|
expect(wrapper.findWhere((node) => node.key() === 'mark_as_unread')).toMatchObject({});
|
|
});
|
|
});
|