More features

This commit is contained in:
2026-06-10 12:43:24 -04:00
parent 02d78765bc
commit dcead245a7
12 changed files with 954 additions and 21 deletions
+19 -10
View File
@@ -28,7 +28,10 @@
(progn
(noise-new-chat-test--setup)
,@body)
(noise-new-chat-test--teardown))))
(noise-new-chat-test--teardown)
(dolist (buf (buffer-list))
(when (string-prefix-p "*signal:" (buffer-name buf))
(kill-buffer buf))))))
(defun noise-new-chat-test--contact (&rest kvs)
"Build a hash table simulating a signal-cli contact from KVS pairs."
@@ -135,13 +138,19 @@
(noise-db-get-conversation-members "+1")))))))
(ert-deftest noise-new-chat-with-contact-is-idempotent ()
"Starting a chat twice should not clobber the existing conversation."
"Starting a chat twice should not clobber the existing conversation.
Opening the conversation marks it read, but history metadata survives."
(noise-new-chat-test--with-db
(noise-db-upsert-conversation "+1" :type "direct" :name "Sarah"
:members '("+1")
:unread-count 3
:last-message-preview "hello")
(noise-new-chat-with-contact "+1" "Sarah")
(let ((conv (noise-db-get-conversation "+1")))
(should (= 3 (gethash "unread_count" conv)))
(should (string= "hello" (gethash "last_message_preview" conv))))))
(unwind-protect
(progn
(noise-db-upsert-conversation "+1" :type "direct" :name "Sarah"
:members '("+1")
:unread-count 3
:last-message-preview "hello")
(noise-new-chat-with-contact "+1" "Sarah")
(let ((conv (noise-db-get-conversation "+1")))
;; opening the chat marks it read
(should (= 0 (gethash "unread_count" conv)))
(should (string= "hello" (gethash "last_message_preview" conv)))))
(when (get-buffer "*signal:Sarah*")
(kill-buffer "*signal:Sarah*")))))