test(webhook): single recipient text stanza shape

Phillip Davis created

Change summary

test/test_webhook_handler.rb | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)

Detailed changes

test/test_webhook_handler.rb 🔗

@@ -241,4 +241,35 @@ class WebhookHandlerTest < Minitest::Test
 		assert_equal 0, entries.length
 	end
 	em :test_message_received_unregistered_jid_writes_no_stanza
+
+	def test_message_received_single_recipient_text_stanza
+		payload = {
+			"type" => "message-received",
+			"to" => "+15550000000",
+			"message" => {
+				"id" => "bw-in-txt-001",
+				"direction" => "in",
+				"owner" => "+15550000000",
+				"from" => "+15551234567",
+				"to" => ["+15550000000"],
+				"time" => "2025-01-13T10:00:00Z",
+				"text" => "Hello from outside"
+			}
+		}
+
+		invoke_webhook(payload)
+
+		assert_equal 1, written.length
+		msg = written.first
+		assert_instance_of Blather::Stanza::Message, msg
+		assert_equal "test@example.com", msg.to.to_s
+		assert_equal "+15551234567@component", msg.from.to_s
+		assert_equal "Hello from outside", msg.body
+		refute msg.find_first("ns:x", ns: "jabber:x:oob")
+		refute msg.find_first(
+			"ns:addresses",
+			ns: "http://jabber.org/protocol/address"
+		)
+	end
+	em :test_message_received_single_recipient_text_stanza
 end