mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-23 15:47:53 -05:00
Merge pull request #5141 from seotts/prevent-feedback-when-not-just-muted
Prevent feedback when not just muted
This commit is contained in:
commit
8271bb62bb
4 changed files with 75 additions and 2 deletions
|
@ -162,7 +162,7 @@ class MuteModal extends React.Component {
|
||||||
)}}
|
)}}
|
||||||
/>
|
/>
|
||||||
</p>
|
</p>
|
||||||
{this.state.step === this.numSteps ? feedbackPrompt : null}
|
{this.state.step === this.numSteps && this.props.showFeedback ? feedbackPrompt : null}
|
||||||
</MuteStep>
|
</MuteStep>
|
||||||
<MuteStep
|
<MuteStep
|
||||||
header={this.props.intl.formatMessage({id: 'comments.muted.mistakeHeader'})}
|
header={this.props.intl.formatMessage({id: 'comments.muted.mistakeHeader'})}
|
||||||
|
|
|
@ -23,6 +23,7 @@ require('./comment.scss');
|
||||||
const onUpdate = update => update;
|
const onUpdate = update => update;
|
||||||
|
|
||||||
const MAX_COMMENT_LENGTH = 500;
|
const MAX_COMMENT_LENGTH = 500;
|
||||||
|
const JUST_MUTED_ERROR = 'isBad';
|
||||||
|
|
||||||
const ComposeStatus = keyMirror({
|
const ComposeStatus = keyMirror({
|
||||||
EDITING: null,
|
EDITING: null,
|
||||||
|
@ -369,7 +370,9 @@ class ComposeComment extends React.Component {
|
||||||
commentContent={this.state.message}
|
commentContent={this.state.message}
|
||||||
muteModalMessages={this.getMuteMessageInfo()}
|
muteModalMessages={this.getMuteMessageInfo()}
|
||||||
shouldCloseOnOverlayClick={false}
|
shouldCloseOnOverlayClick={false}
|
||||||
showFeedback={this.state.status === ComposeStatus.REJECTED_MUTE}
|
showFeedback={
|
||||||
|
this.state.status === ComposeStatus.REJECTED_MUTE && this.state.error === JUST_MUTED_ERROR
|
||||||
|
}
|
||||||
showWarning={this.state.showWarning}
|
showWarning={this.state.showWarning}
|
||||||
startStep={this.getMuteModalStartStep()}
|
startStep={this.getMuteModalStartStep()}
|
||||||
timeMuted={formatTime.formatRelativeTime(this.state.muteExpiresAtMs, window._locale)}
|
timeMuted={formatTime.formatRelativeTime(this.state.muteExpiresAtMs, window._locale)}
|
||||||
|
|
|
@ -304,6 +304,59 @@ describe('Compose Comment test', () => {
|
||||||
expect(component.find('MuteModal').props().showWarning).toBe(true);
|
expect(component.find('MuteModal').props().showWarning).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Mute Modal gets showFeedback props from state', () => {
|
||||||
|
const store = mockStore({
|
||||||
|
session: {
|
||||||
|
session: {
|
||||||
|
user: {},
|
||||||
|
permissions: {
|
||||||
|
mute_status: {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const component = mountWithIntl(
|
||||||
|
<ComposeComment
|
||||||
|
{...defaultProps()}
|
||||||
|
/>
|
||||||
|
, {context: {store}}
|
||||||
|
);
|
||||||
|
|
||||||
|
const commentInstance = component.find('ComposeComment').instance();
|
||||||
|
commentInstance.setState({
|
||||||
|
status: 'REJECTED_MUTE',
|
||||||
|
error: 'isBad',
|
||||||
|
muteOpen: true
|
||||||
|
});
|
||||||
|
|
||||||
|
component.update();
|
||||||
|
expect(component.find('MuteModal').exists()).toEqual(true);
|
||||||
|
expect(component.find('MuteModal').props().showFeedback).toBe(true);
|
||||||
|
|
||||||
|
commentInstance.setState({
|
||||||
|
status: 'REJECTED_MUTE',
|
||||||
|
error: 'isMute',
|
||||||
|
showWarning: true,
|
||||||
|
muteOpen: true
|
||||||
|
});
|
||||||
|
|
||||||
|
component.update();
|
||||||
|
expect(component.find('MuteModal').exists()).toEqual(true);
|
||||||
|
expect(component.find('MuteModal').props().showFeedback).toBe(false);
|
||||||
|
|
||||||
|
commentInstance.setState({
|
||||||
|
status: 'REJECTED',
|
||||||
|
error: 'isBad',
|
||||||
|
showWarning: true,
|
||||||
|
muteOpen: true
|
||||||
|
});
|
||||||
|
|
||||||
|
component.update();
|
||||||
|
expect(component.find('MuteModal').exists()).toEqual(true);
|
||||||
|
expect(component.find('MuteModal').props().showFeedback).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
test('shouldShowMuteModal is false when muteStatus is undefined ', () => {
|
test('shouldShowMuteModal is false when muteStatus is undefined ', () => {
|
||||||
const commentInstance = getComposeCommentWrapper({}).instance();
|
const commentInstance = getComposeCommentWrapper({}).instance();
|
||||||
expect(commentInstance.shouldShowMuteModal()).toBe(false);
|
expect(commentInstance.shouldShowMuteModal()).toBe(false);
|
||||||
|
|
|
@ -160,6 +160,23 @@ describe('MuteModalTest', () => {
|
||||||
expect(component.find('p.feedback-prompt').exists()).toEqual(true);
|
expect(component.find('p.feedback-prompt').exists()).toEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Mute modal does not for feedback on extra showWarning step if not showFeedback', () => {
|
||||||
|
const component = mountWithIntl(
|
||||||
|
<MuteModal
|
||||||
|
showWarning
|
||||||
|
muteModalMessages={defaultMessages}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
component.find('MuteModal').instance()
|
||||||
|
.setState({step: 1});
|
||||||
|
component.update();
|
||||||
|
expect(component.find('p.feedback-prompt').exists()).toEqual(false);
|
||||||
|
component.find('MuteModal').instance()
|
||||||
|
.setState({step: 2});
|
||||||
|
component.update();
|
||||||
|
expect(component.find('p.feedback-prompt').exists()).toEqual(false);
|
||||||
|
});
|
||||||
|
|
||||||
test('Mute modal handle go to feedback', () => {
|
test('Mute modal handle go to feedback', () => {
|
||||||
const component = shallowWithIntl(
|
const component = shallowWithIntl(
|
||||||
<MuteModal
|
<MuteModal
|
||||||
|
|
Loading…
Reference in a new issue