Some testing and fixing receiving messages over SSE

This commit is contained in:
2026-06-14 10:05:23 -04:00
parent 7cdd7aecad
commit 0dd2919fad
4 changed files with 188 additions and 36 deletions
+19
View File
@@ -189,3 +189,22 @@
"timestamp" 1717930000000
"message" "new message here")))
(should (string-match-p "Sarah> new message here" (buffer-string))))))
(ert-deftest noise-receive-handle-sse-event-stores-message ()
"An SSE envelope event stores the message and refreshes the open buffer."
(noise-receive-test--with-db
(noise-db-upsert-conversation "+1" :type "direct" :name "Sarah"
:members '("+1"))
(require 'noise-conversation)
(with-current-buffer (noise-conversation-open "+1")
(noise-receive--handle-sse-event
(noise-receive-test--ht
"envelope"
(noise-receive-test--ht
"sourceNumber" "+1" "sourceName" "Sarah"
"dataMessage" (noise-receive-test--ht
"timestamp" 1717930000000
"message" "from sse"))))
(should (string-match-p "Sarah> from sse" (buffer-string))))
(let ((msg (car (noise-db-get-messages "+1"))))
(should (string= "from sse" (gethash "body" msg))))))