From 936172d70bcda106fd86c9621d955c6c391819f3 Mon Sep 17 00:00:00 2001
From: seotts
Date: Wed, 10 Mar 2021 16:07:31 -0500
Subject: [PATCH 1/2] only show feedback link for new mute
Add variable for isBad string
---
src/components/modal/mute/modal.jsx | 2 +-
src/views/preview/comment/compose-comment.jsx | 5 +-
test/unit/components/compose-comment.test.jsx | 64 +++++++++++++++++++
test/unit/components/mute-modal.test.jsx | 17 +++++
4 files changed, 86 insertions(+), 2 deletions(-)
diff --git a/src/components/modal/mute/modal.jsx b/src/components/modal/mute/modal.jsx
index 1f7a56027..0cd6ec806 100644
--- a/src/components/modal/mute/modal.jsx
+++ b/src/components/modal/mute/modal.jsx
@@ -162,7 +162,7 @@ class MuteModal extends React.Component {
)}}
/>
- {this.state.step === this.numSteps ? feedbackPrompt : null}
+ {this.state.step === this.numSteps && this.props.showFeedback ? feedbackPrompt : null}
update;
const MAX_COMMENT_LENGTH = 500;
+const JUST_MUTED_ERROR = 'isBad';
const ComposeStatus = keyMirror({
EDITING: null,
@@ -363,7 +364,9 @@ class ComposeComment extends React.Component {
commentContent={this.state.message}
muteModalMessages={this.getMuteMessageInfo()}
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}
startStep={this.getMuteModalStartStep()}
timeMuted={formatTime.formatRelativeTime(this.state.muteExpiresAtMs, window._locale)}
diff --git a/test/unit/components/compose-comment.test.jsx b/test/unit/components/compose-comment.test.jsx
index c57cffb75..6b40fee15 100644
--- a/test/unit/components/compose-comment.test.jsx
+++ b/test/unit/components/compose-comment.test.jsx
@@ -304,6 +304,59 @@ describe('Compose Comment test', () => {
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(
+
+ , {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 ', () => {
const commentInstance = getComposeCommentWrapper({}).instance();
expect(commentInstance.shouldShowMuteModal()).toBe(false);
@@ -449,4 +502,15 @@ describe('Compose Comment test', () => {
commentInstance.setState({muteType: 'spaghetti'});
expect(commentInstance.getMuteMessageInfo().commentType).toBe('comment.type.general');
});
+
+ // test('Show feedback link when comment is initially rejected', () => {
+ // const component = getComposeCommentWrapper({});
+ // const commentInstance = component.instance();
+ // commentInstance.setState({error: 'isBad', mute_status: {}});
+ // component.update();
+ // expect(component.find('FlexRow.compose-error-row').exists()).toEqual(true);
+ // // Buttons stay enabled when comment rejected for non-mute reasons
+ // expect(component.find('Button.compose-post').props().disabled).toBe(false);
+ // expect(component.find('Button.compose-cancel').props().disabled).toBe(false);
+ // });
});
diff --git a/test/unit/components/mute-modal.test.jsx b/test/unit/components/mute-modal.test.jsx
index 9601e97fc..5125e38af 100644
--- a/test/unit/components/mute-modal.test.jsx
+++ b/test/unit/components/mute-modal.test.jsx
@@ -160,6 +160,23 @@ describe('MuteModalTest', () => {
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(
+
+ );
+ 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', () => {
const component = shallowWithIntl(
Date: Thu, 11 Mar 2021 16:31:59 -0500
Subject: [PATCH 2/2] remove commented-out test
---
test/unit/components/compose-comment.test.jsx | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/test/unit/components/compose-comment.test.jsx b/test/unit/components/compose-comment.test.jsx
index 6b40fee15..293abb3d7 100644
--- a/test/unit/components/compose-comment.test.jsx
+++ b/test/unit/components/compose-comment.test.jsx
@@ -502,15 +502,4 @@ describe('Compose Comment test', () => {
commentInstance.setState({muteType: 'spaghetti'});
expect(commentInstance.getMuteMessageInfo().commentType).toBe('comment.type.general');
});
-
- // test('Show feedback link when comment is initially rejected', () => {
- // const component = getComposeCommentWrapper({});
- // const commentInstance = component.instance();
- // commentInstance.setState({error: 'isBad', mute_status: {}});
- // component.update();
- // expect(component.find('FlexRow.compose-error-row').exists()).toEqual(true);
- // // Buttons stay enabled when comment rejected for non-mute reasons
- // expect(component.find('Button.compose-post').props().disabled).toBe(false);
- // expect(component.find('Button.compose-cancel').props().disabled).toBe(false);
- // });
});