Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
mattermost-webapp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
sysadmin
mattermost
mattermost-webapp
Commits
0e3bef33
Unverified
Commit
0e3bef33
authored
Dec 12, 2018
by
Joram Wilander
Committed by
cpanato
Dec 12, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MM-13430 Fix /purpose from the post textbox (#2183)
* Fix /purpose from the post textbox * Update tests
parent
9e53e1d0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
16 deletions
+23
-16
components/create_post/create_post.jsx
components/create_post/create_post.jsx
+9
-1
components/create_post/create_post.test.jsx
components/create_post/create_post.test.jsx
+14
-15
No files found.
components/create_post/create_post.jsx
View file @
0e3bef33
...
...
@@ -16,6 +16,7 @@ import * as Utils from 'utils/utils.jsx';
import
ConfirmModal
from
'
components/confirm_modal.jsx
'
;
import
EditChannelHeaderModal
from
'
components/edit_channel_header_modal
'
;
import
EditChannelPurposeModal
from
'
components/edit_channel_purpose_modal
'
;
import
EmojiPickerOverlay
from
'
components/emoji_picker/emoji_picker_overlay.jsx
'
;
import
FilePreview
from
'
components/file_preview/file_preview.jsx
'
;
import
FileUpload
from
'
components/file_upload
'
;
...
...
@@ -480,7 +481,14 @@ export default class CreatePost extends React.Component {
const
isDirectOrGroup
=
((
updateChannel
.
type
===
Constants
.
DM_CHANNEL
)
||
(
updateChannel
.
type
===
Constants
.
GM_CHANNEL
));
if
(
!
isDirectOrGroup
&&
trimRight
(
this
.
state
.
message
)
===
'
/purpose
'
)
{
GlobalActions
.
showChannelPurposeUpdateModal
(
updateChannel
);
const
editChannelPurposeModalData
=
{
modalId
:
ModalIdentifiers
.
EDIT_CHANNEL_PURPOSE
,
dialogType
:
EditChannelPurposeModal
,
dialogProps
:
{
channel
:
updateChannel
},
};
this
.
props
.
actions
.
openModal
(
editChannelPurposeModalData
);
this
.
setState
({
message
:
''
});
return
;
}
...
...
components/create_post/create_post.test.jsx
View file @
0e3bef33
...
...
@@ -17,7 +17,6 @@ import FileUpload from 'components/file_upload';
jest
.
mock
(
'
actions/global_actions.jsx
'
,
()
=>
({
emitLocalUserTypingEvent
:
jest
.
fn
(),
emitUserPostedEvent
:
jest
.
fn
(),
showChannelPurposeUpdateModal
:
jest
.
fn
(),
showChannelNameUpdateModal
:
jest
.
fn
(),
toggleShortcutsModal
:
jest
.
fn
(),
postListScrollChange
:
jest
.
fn
(),
...
...
@@ -339,10 +338,20 @@ describe('components/create_post', () => {
form
.
simulate
(
'
Submit
'
,
{
preventDefault
:
jest
.
fn
()});
expect
(
openModal
).
toHaveBeenCalledTimes
(
1
);
expect
(
openModal
.
mock
.
calls
[
0
][
0
].
modalId
).
toEqual
(
ModalIdentifiers
.
EDIT_CHANNEL_HEADER
);
expect
(
openModal
.
mock
.
calls
[
0
][
0
].
dialogProps
.
channel
).
toEqual
(
currentChannelProp
);
});
it
(
'
onSubmit test for "/purpose" message
'
,
()
=>
{
const
wrapper
=
shallow
(
createPost
());
const
openModal
=
jest
.
fn
();
const
wrapper
=
shallow
(
createPost
({
actions
:
{
...
actionsProp
,
openModal
,
},
})
);
wrapper
.
setState
({
message
:
'
/purpose
'
,
...
...
@@ -350,7 +359,9 @@ describe('components/create_post', () => {
const
form
=
wrapper
.
find
(
'
#create_post
'
);
form
.
simulate
(
'
Submit
'
,
{
preventDefault
:
jest
.
fn
()});
expect
(
GlobalActions
.
showChannelPurposeUpdateModal
).
toHaveBeenCalledWith
(
currentChannelProp
);
expect
(
openModal
).
toHaveBeenCalledTimes
(
1
);
expect
(
openModal
.
mock
.
calls
[
0
][
0
].
modalId
).
toEqual
(
ModalIdentifiers
.
EDIT_CHANNEL_PURPOSE
);
expect
(
openModal
.
mock
.
calls
[
0
][
0
].
dialogProps
.
channel
).
toEqual
(
currentChannelProp
);
});
it
(
'
onSubmit test for "/rename" message
'
,
()
=>
{
...
...
@@ -365,18 +376,6 @@ describe('components/create_post', () => {
expect
(
GlobalActions
.
showChannelNameUpdateModal
).
toHaveBeenCalledWith
(
currentChannelProp
);
});
it
(
'
onSubmit test for "/purpose" message
'
,
()
=>
{
const
wrapper
=
shallow
(
createPost
());
wrapper
.
setState
({
message
:
'
/purpose
'
,
});
const
form
=
wrapper
.
find
(
'
#create_post
'
);
form
.
simulate
(
'
Submit
'
,
{
preventDefault
:
jest
.
fn
()});
expect
(
GlobalActions
.
showChannelPurposeUpdateModal
).
toHaveBeenCalledWith
(
currentChannelProp
);
});
it
(
'
onSubmit test for "/unknown" message
'
,
()
=>
{
jest
.
mock
(
'
actions/channel_actions.jsx
'
,
()
=>
({
executeCommand
:
jest
.
fn
((
message
,
_args
,
resolve
)
=>
resolve
()),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment