Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replybox richtext placeholder with modified behavior #597

Merged
merged 10 commits into from
Nov 8, 2019
Prev Previous commit
call setText when sending a reply
  • Loading branch information
Allie Crevier committed Nov 7, 2019
commit 49d964f65158624b80f6703728339a02ee07f47f
2 changes: 1 addition & 1 deletion securedrop_client/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2345,7 +2345,7 @@ def send_reply(self) -> None:
reply_uuid = str(uuid4())
self.controller.send_reply(self.source.uuid, reply_uuid, reply_text)
self.reply_sent.emit(self.source.uuid, reply_uuid, reply_text)
self.text_edit.clear()
self.text_edit.setText('')

def _on_authentication_changed(self, authenticated: bool) -> None:
if authenticated:
Expand Down
20 changes: 19 additions & 1 deletion tests/gui/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2215,15 +2215,33 @@ def test_ReplyBoxWidget_send_reply(mocker):
scw.conversation_view.on_reply_sent = on_reply_sent_fn
scw.reply_box.reply_sent = mocker.MagicMock()
scw.reply_box.text_edit = ReplyTextEdit(source, controller)
scw.reply_box.text_edit.setText = mocker.MagicMock()
scw.reply_box.text_edit.setPlainText('Alles für Alle')

scw.reply_box.send_reply()

scw.reply_box.reply_sent.emit.assert_called_once_with('abc123', '456xyz', 'Alles für Alle')
assert scw.reply_box.text_edit.toPlainText() == ''
scw.reply_box.text_edit.setText.assert_called_once_with('')
controller.send_reply.assert_called_once_with('abc123', '456xyz', 'Alles für Alle')


def test_ReplyBoxWidget_send_reply_calls_setText_after_send(mocker):
"""
Ensure sending a reply from the reply box emits signal, clears text box, and sends the reply
details to the controller.
"""
source = factory.Source()
controller = mocker.MagicMock()
rb = ReplyBoxWidget(source, controller)
rb.text_edit = ReplyTextEdit(source, controller)
setText = mocker.patch.object(rb.text_edit, 'setText')
rb.text_edit.setPlainText('Alles für Alle')

rb.send_reply()

setText.assert_called_once_with('')


def test_ReplyBoxWidget_send_reply_does_not_send_empty_string(mocker):
"""
Ensure sending a reply from the reply box does not send empty string.
Expand Down