This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* MM-15751 Fix for system messages not rendering in IE * Add a new utility function which accepts posts and creates combines system messages * Add test case for combined messages when posts greater than 100 * Chnages based on redux repo changes * Fix for ordering files * Update redux hash * Update redux hash
- Loading branch information
1 parent
dc42734
commit 79840f9
Showing
8 changed files
with
168 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import {Posts} from 'mattermost-redux/constants'; | ||
import * as PostListUtils from 'mattermost-redux/utils/post_list'; | ||
|
||
import {makeCombineUserActivityFromPosts} from './posts'; | ||
|
||
describe('makeCombineUserActivityFromPosts', () => { | ||
test('should do nothing if no post IDs are provided', () => { | ||
const combineUserActivityPosts = makeCombineUserActivityFromPosts(); | ||
|
||
const posts = []; | ||
|
||
const result = combineUserActivityPosts(posts); | ||
|
||
expect(result).toBe(posts); | ||
expect(result).toEqual([]); | ||
}); | ||
|
||
test('should do nothing if there are no user activity posts', () => { | ||
const combineUserActivityPosts = makeCombineUserActivityFromPosts(); | ||
const posts = [ | ||
{id: 'post1'}, | ||
{id: 'post2'}, | ||
{id: 'post3'}, | ||
]; | ||
const result = combineUserActivityPosts(posts); | ||
|
||
expect(result).toBe(posts); | ||
}); | ||
|
||
test('should combine adjacent user activity posts', () => { | ||
const combineUserActivityPosts = makeCombineUserActivityFromPosts(); | ||
|
||
const posts = [ | ||
{id: 'post1', type: Posts.POST_TYPES.JOIN_CHANNEL}, | ||
{id: 'post2', type: Posts.POST_TYPES.LEAVE_CHANNEL}, | ||
{id: 'post3', type: Posts.POST_TYPES.ADD_TO_CHANNEL}, | ||
]; | ||
|
||
const result = combineUserActivityPosts(posts); | ||
|
||
expect(result).not.toBe(posts); | ||
expect(result).toEqual([ | ||
{id: PostListUtils.COMBINED_USER_ACTIVITY + 'post1_post2_post3', type: Posts.POST_TYPES.JOIN_CHANNEL}, | ||
]); | ||
}); | ||
|
||
test('should not combine with regular messages', () => { | ||
const combineUserActivityPosts = makeCombineUserActivityFromPosts(); | ||
|
||
const posts = [ | ||
{id: 'post1', type: Posts.POST_TYPES.JOIN_CHANNEL}, | ||
{id: 'post2', type: Posts.POST_TYPES.JOIN_CHANNEL}, | ||
{id: 'post3'}, | ||
{id: 'post4', type: Posts.POST_TYPES.ADD_TO_CHANNEL}, | ||
{id: 'post5', type: Posts.POST_TYPES.ADD_TO_CHANNEL}, | ||
]; | ||
|
||
const result = combineUserActivityPosts(posts); | ||
|
||
expect(result).not.toBe(posts); | ||
expect(result).toEqual([ | ||
{id: PostListUtils.COMBINED_USER_ACTIVITY + 'post1_post2', type: Posts.POST_TYPES.JOIN_CHANNEL}, | ||
{id: 'post3'}, | ||
{id: PostListUtils.COMBINED_USER_ACTIVITY + 'post4_post5', type: Posts.POST_TYPES.ADD_TO_CHANNEL}, | ||
]); | ||
}); | ||
|
||
test('should not combine more than 100 posts', () => { | ||
const combineUserActivityPosts = makeCombineUserActivityFromPosts(); | ||
|
||
const posts = []; | ||
for (let i = 0; i < 110; i++) { | ||
const postId = `post${i}`; | ||
posts.push({id: postId, type: Posts.POST_TYPES.JOIN_CHANNEL}); | ||
} | ||
|
||
const result = combineUserActivityPosts(posts); | ||
|
||
expect(result).toHaveLength(2); | ||
}); | ||
}); |