test(webhook): failure sends one error

Phillip Davis created

Change summary

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

Detailed changes

test/property/test_webhook_handler.rb 🔗

@@ -72,4 +72,33 @@ class WebhookPropertyTest < Minitest::Test
 		}
 	end
 	em :test_multi_recipient_outbound_sends_no_receipts
+
+	def test_single_recipient_message_failed_sends_one_error
+		property_of {
+			Webhook
+				.new(REDIS)
+				.type { "message-failed" }
+				.message { |registered, jid, dir, top_level_to|
+					Message
+						.new(REDIS)
+						.to { [top_level_to] }
+						.generate(registered, jid, dir)
+				}
+				.generate
+		}.check { |metadata, example|
+			result = invoke_webhook(example)
+			assert_equal 200, result[0]
+			assert_equal(
+				written.length,
+				1,
+				"Message failed should only send one notification"
+			)
+			assert_kind_of(
+				::Blather::StanzaError,
+				written.shift,
+				"Should not notify message-failed"
+			)
+		}
+	end
+	em :test_single_recipient_message_failed_sends_one_error
 end