From 894756addc6295708c45e872a5f54534b8d06ad2 Mon Sep 17 00:00:00 2001 From: Varun Singh Date: Thu, 28 Mar 2024 12:54:44 +0530 Subject: [PATCH] submessage: Replace bogus test data with valid objects. The test data was not the correct representation of submessage's content field. This caused the zod schema to throw error. This is a temporary solution and eventually we have to move to an efficient approach making the test data more representative and accurate. Discussion: https://chat.zulip.org/#narrow/stream/6-frontend/topic/TypeScript.20migration/near/1766122 --- web/tests/submessage.test.js | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/web/tests/submessage.test.js b/web/tests/submessage.test.js index e860cff822..2742d7b101 100644 --- a/web/tests/submessage.test.js +++ b/web/tests/submessage.test.js @@ -23,8 +23,12 @@ run_test("get_message_events", () => { assert.equal(submessage.get_message_events(msg), undefined); const submessages = [ - {id: 222, sender_id: 99, content: "84"}, - {id: 9, sender_id: 33, content: "42"}, + {id: 222, sender_id: 99, content: '{"type":"new_option","idx":1,"option":"bar"}'}, + { + id: 9, + sender_id: 33, + content: '{"widget_type": "poll", "extra_data": {"question": "foo", "options": []}}', + }, ]; msg = { @@ -37,8 +41,24 @@ run_test("get_message_events", () => { submessages, }; assert.deepEqual(submessage.get_message_events(msg), [ - {sender_id: 33, data: 42}, - {sender_id: 99, data: 84}, + { + sender_id: 33, + data: { + widget_type: "poll", + extra_data: { + question: "foo", + options: [], + }, + }, + }, + { + sender_id: 99, + data: { + type: "new_option", + idx: 1, + option: "bar", + }, + }, ]); }); @@ -73,7 +93,13 @@ run_test("check sender", ({override}) => { const message = { id: message_id, sender_id: 1, - submessages: [{sender_id: 2, content: "{}"}], + submessages: [ + { + sender_id: 2, + content: + '{"widget_type": "poll", "extra_data": {"question": "foo", "options": []}}', + }, + ], }; override(message_store, "get", (arg) => {