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.
Update mattermost-redux to deduplicate retrying posts. (#1132)
This restores some of 8e1241a with changes to reflect the relocated logic into mattermost-redux. Note that the retry component never actually supported handling the `api.post.craete_post.root_id.app_error` error: `showPostDeletedModal` was never implemented. Hence the simple removal of this code: a separate JIRA issue will be filed to track the root post deletion case.
- Loading branch information
1 parent
fc05769
commit e64cfa2
Showing
6 changed files
with
105 additions
and
44 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
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
31 changes: 31 additions & 0 deletions
31
tests/components/post_view/__snapshots__/failed_post_options.test.jsx.snap
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,31 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`components/post_view/FailedPostOptions should match snapshot 1`] = ` | ||
<span | ||
className="pending-post-actions" | ||
> | ||
<a | ||
className="post-retry" | ||
href="#" | ||
onClick={[Function]} | ||
> | ||
<FormattedMessage | ||
defaultMessage="Retry" | ||
id="pending_post_actions.retry" | ||
values={Object {}} | ||
/> | ||
</a> | ||
- | ||
<a | ||
className="post-cancel" | ||
href="#" | ||
onClick={[Function]} | ||
> | ||
<FormattedMessage | ||
defaultMessage="Cancel" | ||
id="pending_post_actions.cancel" | ||
values={Object {}} | ||
/> | ||
</a> | ||
</span> | ||
`; |
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,59 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See License.txt for license information. | ||
|
||
import React from 'react'; | ||
import {shallow} from 'enzyme'; | ||
|
||
import FailedPostOptions from 'components/post_view/failed_post_options/failed_post_options.jsx'; | ||
|
||
describe('components/post_view/FailedPostOptions', () => { | ||
const baseProps = { | ||
post: { | ||
id: 'post_id', | ||
}, | ||
actions: { | ||
createPost: jest.fn(), | ||
removePost: jest.fn(), | ||
}, | ||
}; | ||
|
||
test('should match snapshot', () => { | ||
const wrapper = shallow(<FailedPostOptions {...baseProps}/>); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
test('should create post on retry', () => { | ||
const props = { | ||
...baseProps, | ||
actions: { | ||
...baseProps.actions, | ||
createPost: jest.fn(), | ||
}, | ||
}; | ||
|
||
const wrapper = shallow(<FailedPostOptions {...props}/>); | ||
const e = {preventDefault: jest.fn()}; | ||
|
||
wrapper.find('.post-retry').simulate('click', e); | ||
expect(props.actions.createPost.mock.calls.length).toBe(1); | ||
|
||
wrapper.find('.post-retry').simulate('click', e); | ||
expect(props.actions.createPost.mock.calls.length).toBe(2); | ||
}); | ||
|
||
test('should remove post on cancel', () => { | ||
const props = { | ||
...baseProps, | ||
actions: { | ||
...baseProps.actions, | ||
removePost: jest.fn(), | ||
}, | ||
}; | ||
|
||
const wrapper = shallow(<FailedPostOptions {...props}/>); | ||
const e = {preventDefault: jest.fn()}; | ||
|
||
wrapper.find('.post-cancel').simulate('click', e); | ||
expect(props.actions.removePost.mock.calls.length).toBe(1); | ||
}); | ||
}); |