mirror of https://github.com/zulip/zulip.git
tests: Improve automated tests for submessages.
Added an additional test case to `test_submessages.py` for testing the message object containing `submessages` meta data. Previous to this commit we were never validating the `submessage` schema in the `message` objects. Fixes #25896.
This commit is contained in:
parent
362a63ea5d
commit
46b582689a
|
@ -18080,7 +18080,7 @@ components:
|
|||
type: integer
|
||||
description: |
|
||||
The ID of the user who sent the message.
|
||||
submessage_id:
|
||||
id:
|
||||
type: integer
|
||||
description: |
|
||||
The ID of the submessage.
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue