Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
tests: Improve automated tests for submessages.
Lalit46b582689aab
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yamlindex 7a89b803405..543ab9f5437 100644--- a/zerver/openapi/zulip.yaml+++ b/zerver/openapi/zulip.yaml@@ -18080,7 +18080,7 @@ components:type: integerdescription: |The ID of the user who sent the message.- submessage_id:+ id:type: integerdescription: |The ID of the submessage.diff --git a/zerver/tests/test_submessage.py b/zerver/tests/test_submessage.pyindex 72453d2ddcd..394c85ba3ab 100644--- a/zerver/tests/test_submessage.py+++ b/zerver/tests/test_submessage.py@@ -200,3 +200,33 @@ class TestBasics(ZulipTestCase):"Events should be sent only after the transaction commits.")do_add_submessage(hamlet.realm, hamlet.id, message_id, "whatever", "whatever")++ def test_fetch_message_containing_submessages(self) -> None:+ cordelia = self.example_user("cordelia")+ stream_name = "Verona"+ message_id = self.send_stream_message(+ sender=cordelia,+ stream_name=stream_name,+ )+ self.login_user(cordelia)++ payload = dict(+ message_id=message_id,+ msg_type="whatever",+ content='{"name": "alice", "salary": 20}',+ )+ self.assert_json_success(self.client_post("/json/submessage", payload))++ result = self.client_get(f"/json/messages/{message_id}")+ response_dict = self.assert_json_success(result)+ self.assert_length(response_dict["message"]["submessages"], 1)++ submessage = response_dict["message"]["submessages"][0]+ expected_data = dict(+ id=submessage["id"],+ message_id=message_id,+ content='{"name": "alice", "salary": 20}',+ msg_type="whatever",+ sender_id=cordelia.id,+ )+ self.assertEqual(submessage, expected_data)