Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
92667c09
Commit
92667c09
authored
Feb 04, 2021
by
picklesrus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests and expose steps enum so it can be referenced from outside MuteModal
parent
f7bf2049
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
3 deletions
+44
-3
src/components/modal/mute/modal.jsx
src/components/modal/mute/modal.jsx
+2
-2
src/views/preview/comment/compose-comment.jsx
src/views/preview/comment/compose-comment.jsx
+1
-1
test/unit/components/compose-comment.test.jsx
test/unit/components/compose-comment.test.jsx
+41
-0
No files found.
src/components/modal/mute/modal.jsx
View file @
92667c09
...
@@ -240,8 +240,8 @@ MuteModal.propTypes = {
...
@@ -240,8 +240,8 @@ MuteModal.propTypes = {
}),
}),
onRequestClose
:
PropTypes
.
func
,
onRequestClose
:
PropTypes
.
func
,
showWarning
:
PropTypes
.
bool
,
showWarning
:
PropTypes
.
bool
,
startStep
:
PropTypes
.
number
,
startStep
:
PropTypes
.
oneOf
(
Object
.
keys
(
steps
))
,
timeMuted
:
PropTypes
.
string
timeMuted
:
PropTypes
.
string
};
};
MuteModal
.
steps
=
steps
;
module
.
exports
=
injectIntl
(
MuteModal
);
module
.
exports
=
injectIntl
(
MuteModal
);
src/views/preview/comment/compose-comment.jsx
View file @
92667c09
...
@@ -344,7 +344,7 @@ class ComposeComment extends React.Component {
...
@@ -344,7 +344,7 @@ class ComposeComment extends React.Component {
muteModalMessages=
{
this
.
getMuteMessageInfo
()
}
muteModalMessages=
{
this
.
getMuteMessageInfo
()
}
shouldCloseOnOverlayClick=
{
false
}
shouldCloseOnOverlayClick=
{
false
}
showWarning=
{
this
.
state
.
showWarning
}
showWarning=
{
this
.
state
.
showWarning
}
startStep=
{
this
.
props
.
isReply
?
1
:
0
}
startStep=
{
this
.
props
.
isReply
?
MuteModal
.
steps
.
MUTE_INFO
:
MuteModal
.
steps
.
COMMENT_ISSUE
}
timeMuted=
{
formatTime
.
formatRelativeTime
(
this
.
state
.
muteExpiresAtMs
,
window
.
_locale
)
}
timeMuted=
{
formatTime
.
formatRelativeTime
(
this
.
state
.
muteExpiresAtMs
,
window
.
_locale
)
}
onRequestClose=
{
this
.
handleMuteClose
}
onRequestClose=
{
this
.
handleMuteClose
}
/>
/>
...
...
test/unit/components/compose-comment.test.jsx
View file @
92667c09
...
@@ -101,6 +101,46 @@ describe('Compose Comment test', () => {
...
@@ -101,6 +101,46 @@ describe('Compose Comment test', () => {
global
.
Date
.
now
=
realDateNow
;
global
.
Date
.
now
=
realDateNow
;
});
});
test
(
'
Comment Status and compose box do not show on replies when muted, but mute modal does
'
,
()
=>
{
const
realDateNow
=
Date
.
now
.
bind
(
global
.
Date
);
global
.
Date
.
now
=
()
=>
0
;
const
store
=
mockStore
({
session
:
{
session
:
{
user
:
{},
permissions
:
{
mute_status
:
{
muteExpiresAt
:
5
,
offenses
:
[],
showWarning
:
true
}
}
}
}
});
const
component
=
mountWithIntl
(
<
ComposeComment
{
...
defaultProps
()}
isReply
/>
,
{
context
:
{
store
}}
);
expect
(
component
.
find
(
'
FlexRow.compose-comment
'
).
exists
()).
toEqual
(
false
);
expect
(
component
.
find
(
'
MuteModal
'
).
exists
()).
toBe
(
true
);
expect
(
component
.
find
(
'
MuteModal
'
).
props
().
startStep
).
toBe
(
1
);
expect
(
component
.
find
(
'
CommentingStatus
'
).
exists
()).
toEqual
(
false
);
global
.
Date
.
now
=
realDateNow
;
});
test
(
'
Comment Status and compose box show on replies when not muted
'
,
()
=>
{
const
realDateNow
=
Date
.
now
.
bind
(
global
.
Date
);
global
.
Date
.
now
=
()
=>
0
;
const
component
=
getComposeCommentWrapper
({
isReply
:
true
});
expect
(
component
.
find
(
'
FlexRow.compose-comment
'
).
exists
()).
toEqual
(
true
);
expect
(
component
.
find
(
'
CommentingStatus
'
).
exists
()).
toEqual
(
false
);
global
.
Date
.
now
=
realDateNow
;
});
test
(
'
Comment Status initialized properly when muted
'
,
()
=>
{
test
(
'
Comment Status initialized properly when muted
'
,
()
=>
{
jest
.
useFakeTimers
();
jest
.
useFakeTimers
();
const
realDateNow
=
Date
.
now
.
bind
(
global
.
Date
);
const
realDateNow
=
Date
.
now
.
bind
(
global
.
Date
);
...
@@ -207,6 +247,7 @@ describe('Compose Comment test', () => {
...
@@ -207,6 +247,7 @@ describe('Compose Comment test', () => {
commentInstance
.
setState
({
muteOpen
:
true
});
commentInstance
.
setState
({
muteOpen
:
true
});
component
.
update
();
component
.
update
();
expect
(
component
.
find
(
'
MuteModal
'
).
exists
()).
toEqual
(
true
);
expect
(
component
.
find
(
'
MuteModal
'
).
exists
()).
toEqual
(
true
);
expect
(
component
.
find
(
'
MuteModal
'
).
props
().
startStep
).
toEqual
(
0
);
expect
(
component
.
find
(
'
MuteModal
'
).
props
().
showWarning
).
toBe
(
false
);
expect
(
component
.
find
(
'
MuteModal
'
).
props
().
showWarning
).
toBe
(
false
);
global
.
Date
.
now
=
realDateNow
;
global
.
Date
.
now
=
realDateNow
;
});
});
...
...
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