]> git.notmuchmail.org Git - notmuch/blob - test/emacs
test: `notmuch-show-advance-and-archive' with invisible signature
[notmuch] / test / emacs
1 #!/usr/bin/env bash
2
3 test_description="emacs interface"
4 . test-lib.sh
5
6 EXPECTED=$TEST_DIRECTORY/emacs.expected-output
7
8 add_email_corpus
9
10 test_begin_subtest "Basic notmuch-hello view in emacs"
11 test_emacs '(notmuch-hello)
12             (test-output)'
13 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello
14
15 test_begin_subtest "Saved search with 0 results"
16 test_emacs '(let ((notmuch-show-empty-saved-searches t)
17                   (notmuch-saved-searches
18                    '\''(("inbox" . "tag:inbox")
19                         ("unread" . "tag:unread")
20                         ("empty" . "tag:doesnotexist"))))
21               (notmuch-hello)
22               (test-output))'
23 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-with-empty
24
25 test_begin_subtest "No saved searches displayed (all with 0 results)"
26 test_emacs '(let ((notmuch-saved-searches
27                    '\''(("empty" . "tag:doesnotexist"))))
28               (notmuch-hello)
29               (test-output))'
30 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-no-saved-searches
31
32 test_begin_subtest "Basic notmuch-search view in emacs"
33 test_emacs '(notmuch-search "tag:inbox")
34             (notmuch-test-wait)
35             (test-output)'
36 test_expect_equal_file OUTPUT $EXPECTED/notmuch-search-tag-inbox
37
38 test_begin_subtest "Navigation of notmuch-hello to search results"
39 test_emacs '(notmuch-hello)
40             (goto-char (point-min))
41             (re-search-forward "inbox")
42             (widget-button-press (point))
43             (notmuch-test-wait)
44             (test-output)'
45 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-view-inbox
46
47 test_begin_subtest "Basic notmuch-show view in emacs"
48 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
49 test_emacs "(notmuch-show \"$maildir_storage_thread\")
50             (test-output)"
51 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
52
53 test_begin_subtest "notmuch-show for message with invalid From"
54 add_message "[subject]=\"message-with-invalid-from\"" \
55             "[from]=\"\\\"Invalid \\\" From\\\" <test_suite@notmuchmail.org>\""
56 thread=$(notmuch search --output=threads subject:message-with-invalid-from)
57 test_emacs "(notmuch-show \"$thread\")
58             (test-output)"
59 cat <<EOF >EXPECTED
60 "Invalid " From" <test_suite@notmuchmail.org> (2001-01-05) (inbox)
61 Subject: message-with-invalid-from
62 To: Notmuch Test Suite <test_suite@notmuchmail.org>
63 Date: Tue, 05 Jan 2001 15:43:57 -0000
64
65 This is just a test message (#1)
66 EOF
67 test_expect_equal_file OUTPUT EXPECTED
68
69 test_begin_subtest "Navigation of notmuch-search to thread view"
70 test_emacs '(notmuch-search "tag:inbox")
71             (notmuch-test-wait)
72             (goto-char (point-min))
73             (re-search-forward "Working with Maildir")
74             (notmuch-search-show-thread)
75             (notmuch-test-wait)
76             (test-output)'
77 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
78
79 test_begin_subtest "Add tag from search view"
80 os_x_darwin_thread=$(notmuch search --output=threads id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com)
81 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
82             (notmuch-test-wait)
83             (notmuch-search-add-tag \"tag-from-search-view\")"
84 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
85 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-search-view unread)"
86
87 test_begin_subtest "Remove tag from search view"
88 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
89             (notmuch-test-wait)
90             (notmuch-search-remove-tag \"tag-from-search-view\")"
91 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
92 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)"
93
94 test_begin_subtest "Add tag from notmuch-show view"
95 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
96             (notmuch-show-add-tag \"tag-from-show-view\")"
97 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
98 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-show-view unread)"
99
100 test_begin_subtest "Remove tag from notmuch-show view"
101 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
102             (notmuch-show-remove-tag \"tag-from-show-view\")"
103 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
104 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)"
105
106 test_begin_subtest "Message with .. in Message-Id:"
107 add_message [id]=123..456@example '[subject]="Message with .. in Message-Id"'
108 test_emacs '(notmuch-search "id:\"123..456@example\"")
109             (notmuch-test-wait)
110             (notmuch-search-add-tag "search-add")
111             (notmuch-search-add-tag "search-remove")
112             (notmuch-search-remove-tag "search-remove")
113             (notmuch-show "id:\"123..456@example\"")
114             (notmuch-test-wait)
115             (notmuch-show-add-tag "show-add")
116             (notmuch-show-add-tag "show-remove")
117             (notmuch-show-remove-tag "show-remove")'
118 output=$(notmuch search 'id:"123..456@example"' | notmuch_search_sanitize)
119 test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Message with .. in Message-Id (inbox search-add show-add)"
120
121 test_begin_subtest "Sending a message via (fake) SMTP"
122 emacs_deliver_message \
123     'Testing message sent via SMTP' \
124     'This is a test that messages are sent via SMTP' \
125     '(message-goto-to)
126      (kill-whole-line)
127      (insert "To: user@example.com\n")'
128 sed \
129     -e s',^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' \
130     -e s',^Message-ID: <.*>$,Message-ID: <XXX>,' < sent_message >OUTPUT
131 cat <<EOF >EXPECTED
132 From: Notmuch Test Suite <test_suite@notmuchmail.org>
133 To: user@example.com
134 Subject: Testing message sent via SMTP
135 Date: 01 Jan 2000 12:00:00 -0000
136 User-Agent: Notmuch/XXX Emacs/XXX
137 Message-ID: <XXX>
138 MIME-Version: 1.0
139 Content-Type: text/plain; charset=us-ascii
140
141 This is a test that messages are sent via SMTP
142 EOF
143 test_expect_equal_file OUTPUT EXPECTED
144
145 test_begin_subtest "Verify that sent messages are saved/searchable (via FCC)"
146 notmuch new > /dev/null
147 output=$(notmuch search 'subject:"testing message sent via SMTP"' | notmuch_search_sanitize)
148 test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; Testing message sent via SMTP (inbox)"
149
150 test_begin_subtest "notmuch-fcc-dirs set to nil"
151 test_emacs "(let ((notmuch-fcc-dirs nil))
152               (notmuch-mua-mail)
153               (test-output))"
154 cat <<EOF >EXPECTED
155 From: Notmuch Test Suite <test_suite@notmuchmail.org>
156 To: 
157 Subject: 
158 --text follows this line--
159 EOF
160 test_expect_equal_file OUTPUT EXPECTED
161
162 # Make another FCC maildir specific for the next test
163 mkdir -p mail/sent-string/cur
164 mkdir -p mail/sent-string/new
165 mkdir -p mail/sent-string/tmp
166
167 test_begin_subtest "notmuch-fcc-dirs set to a string"
168 test_emacs "(let ((notmuch-fcc-dirs \"sent-string\"))
169               (notmuch-mua-mail)
170               (test-output))"
171 cat <<EOF >EXPECTED
172 From: Notmuch Test Suite <test_suite@notmuchmail.org>
173 To: 
174 Subject: 
175 Fcc: ${MAIL_DIR}/sent-string
176 --text follows this line--
177 EOF
178 test_expect_equal_file OUTPUT EXPECTED
179
180 # Make more FCC maildirs specific for the next test
181 mkdir -p mail/sent-list-match/cur
182 mkdir -p mail/sent-list-match/new
183 mkdir -p mail/sent-list-match/tmp
184 mkdir -p mail/failure/cur
185 mkdir -p mail/failure/new
186 mkdir -p mail/failure/tmp
187
188 test_begin_subtest "notmuch-fcc-dirs set to a list (with match)"
189 test_emacs "(let ((notmuch-fcc-dirs
190                    '((\"notmuchmail.org\" . \"sent-list-match\")
191                      (\".*\" . \"failure\"))))
192               (notmuch-mua-mail)
193               (test-output))"
194 cat <<EOF >EXPECTED
195 From: Notmuch Test Suite <test_suite@notmuchmail.org>
196 To: 
197 Subject: 
198 Fcc: ${MAIL_DIR}/sent-list-match
199 --text follows this line--
200 EOF
201 test_expect_equal_file OUTPUT EXPECTED
202
203 # Make another FCC maildir specific for the next test
204 mkdir -p mail/sent-list-catch-all/cur
205 mkdir -p mail/sent-list-catch-all/new
206 mkdir -p mail/sent-list-catch-all/tmp
207  
208 test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)"
209 test_emacs "(let ((notmuch-fcc-dirs
210                    '((\"example.com\" . \"failure\")
211                      (\".*\" . \"sent-list-catch-all\"))))
212               (notmuch-mua-mail)
213               (test-output))"
214 cat <<EOF >EXPECTED
215 From: Notmuch Test Suite <test_suite@notmuchmail.org>
216 To: 
217 Subject: 
218 Fcc: ${MAIL_DIR}/sent-list-catch-all
219 --text follows this line--
220 EOF
221 test_expect_equal_file OUTPUT EXPECTED
222
223 test_begin_subtest "notmuch-fcc-dirs set to a list (no match)"
224 test_emacs "(let ((notmuch-fcc-dirs
225                    '((\"example.com\" . \"failure\")
226                      (\"nomatchhere.net\" . \"failure\"))))
227               (notmuch-mua-mail)
228               (test-output))"
229 cat <<EOF >EXPECTED
230 From: Notmuch Test Suite <test_suite@notmuchmail.org>
231 To: 
232 Subject: 
233 --text follows this line--
234 EOF
235 test_expect_equal_file OUTPUT EXPECTED
236
237 test_begin_subtest "Reply within emacs"
238 test_emacs '(notmuch-search "subject:\"testing message sent via SMTP\"")
239             (notmuch-test-wait)
240             (notmuch-search-reply-to-thread)
241             (test-output)'
242 sed -i -e 's/^In-Reply-To: <.*>$/In-Reply-To: <XXX>/' OUTPUT
243 cat <<EOF >EXPECTED
244 From: Notmuch Test Suite <test_suite@notmuchmail.org>
245 To: user@example.com
246 Subject: Re: Testing message sent via SMTP
247 In-Reply-To: <XXX>
248 Fcc: $(pwd)/mail/sent
249 --text follows this line--
250 On 01 Jan 2000 12:00:00 -0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
251 > This is a test that messages are sent via SMTP
252 EOF
253 test_expect_equal_file OUTPUT EXPECTED
254
255 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-attachments"
256 # save as archive to test that Emacs does not re-compress .gz
257 test_emacs '(let ((standard-input "\"attachment1.gz\""))
258               (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
259               (notmuch-show-save-attachments))' > /dev/null 2>&1
260 test_expect_equal_file attachment1.gz "$EXPECTED/attachment"
261
262 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-part"
263 # save as archive to test that Emacs does not re-compress .gz
264 test_emacs '(let ((standard-input "\"attachment2.gz\""))
265               (notmuch-show-save-part "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com" 5))' > /dev/null 2>&1
266 test_expect_equal_file attachment2.gz "$EXPECTED/attachment"
267
268 test_begin_subtest "View raw message within emacs"
269 test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
270             (notmuch-show-view-raw-message)
271             (test-output)'
272 test_expect_equal_file OUTPUT $EXPECTED/raw-message-cf0c4d-52ad0a
273
274 test_begin_subtest "Hiding/showing signature in notmuch-show view"
275 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
276 test_emacs "(notmuch-show \"$maildir_storage_thread\")
277             (search-forward \"Click/Enter to show.\")
278             (button-activate (button-at (point)))
279             (search-backward \"Click/Enter to hide.\")
280             (button-activate (button-at (point)))
281             (test-output)"
282 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
283
284 test_begin_subtest "Detection and hiding of top-post quoting of message"
285 add_message '[subject]="The problem with top-posting"' \
286             [id]=top-post-target \
287             '[body]="A: Because it messes up the order in which people normally read text.
288 Q: Why is top-posting such a bad thing?
289 A: Top-posting.
290 Q: What is the most annoying thing in e-mail?"'
291 add_message '[from]="Top Poster <top@poster.com>"' \
292             [in-reply-to]=top-post-target \
293             [references]=top-post-target \
294             '[subject]="Re: The problem with top-posting"' \
295             '[body]="Thanks for the advice! I will be sure to put it to good use.
296
297 -Top Poster
298
299 ----- Original Message -----
300 From: Notmuch Test Suite <test_suite@notmuchmail.org>
301 To: Notmuch Test Suite <test_suite@notmuchmai.org>
302 Sent: Tue, 05 Jan 2001 15:43:57 -0000
303 Subject: The problem with top-posting
304
305 Q: Why is top-posting such a bad thing?
306 A: Top-posting.
307 Q: What is the most annoying thing in e-mail?"'
308 test_emacs "(notmuch-show \"top-posting\")
309             (test-visible-output)"
310 echo "Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
311 Subject: The problem with top-posting
312 To: Notmuch Test Suite <test_suite@notmuchmail.org>
313 Date: Tue, 05 Jan 2001 15:43:57 -0000
314
315 A: Because it messes up the order in which people normally read text.
316 Q: Why is top-posting such a bad thing?
317 A: Top-posting.
318 Q: What is the most annoying thing in e-mail?
319 Top Poster <top@poster.com> (2001-01-05) (inbox unread)
320 Subject: Re: The problem with top-posting
321 To: Notmuch Test Suite <test_suite@notmuchmail.org>
322 Date: Tue, 05 Jan 2001 15:43:57 -0000
323
324 Thanks for the advice! I will be sure to put it to good use.
325
326 -Top Poster
327
328 [ 9-line hidden original message. Click/Enter to show. ]" > EXPECTED
329 test_expect_equal_file OUTPUT EXPECTED
330
331 test_begin_subtest "Hiding message in notmuch-show view"
332 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
333             (notmuch-show-toggle-message)
334             (test-visible-output)'
335 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
336
337 test_begin_subtest "Hiding message with visible citation in notmuch-show view"
338 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
339             (search-forward "Click/Enter to show.")
340             (button-activate (button-at (point)))
341             (notmuch-show-toggle-message)
342             (test-visible-output)'
343 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
344
345 test_begin_subtest 'Hiding message following HTML part'
346 test_subtest_known_broken
347 id='html-message@notmuchmail.org'
348 emacs_deliver_message \
349     'HTML message' \
350     '' \
351     "(message-goto-eoh)
352      (insert \"Message-ID: <$id>\n\")
353      (message-goto-body)
354      (mml-insert-part \"text/html\")
355      (insert \"<body>This is a test HTML message</body>\")"
356 emacs_deliver_message \
357     'Reply to HTML message' \
358     'This is a reply to the test HTML message' \
359     "(message-goto-eoh)
360      (insert \"In-Reply-To: <$id>\n\")"
361 test_emacs "(notmuch-show \"id:$id\") \
362             (notmuch-show-next-message) \
363             (command-execute (key-binding (kbd \"RET\"))) \
364             (test-visible-output)"
365 test_emacs "(notmuch-show \"id:$id\") \
366             (notmuch-show-next-message) \
367             (notmuch-show-toggle-message) \
368             (test-visible-output \"EXPECTED\")"
369 test_expect_equal_file OUTPUT EXPECTED
370
371 test_begin_subtest 'notmuch-show-advance-and-archive with invisible signature'
372 test_subtest_known_broken
373 message1='id:20091118010116.GC25380@dottiness.seas.harvard.edu'
374 message2='id:1258491078-29658-1-git-send-email-dottedmag@dottedmag.net'
375 test_emacs "(notmuch-search \"$message1 or $message2\")
376             (notmuch-test-wait)
377             (notmuch-search-show-thread)
378             (goto-char (point-max))
379             (redisplay)
380             (notmuch-show-advance-and-archive)
381             (test-output)"
382 test_emacs "(notmuch-show \"$message2\")
383             (test-output \"EXPECTED\")"
384 test_expect_equal_file OUTPUT EXPECTED
385
386 test_begin_subtest "Refresh show buffer"
387 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
388             (test-visible-output "EXPECTED")
389             (notmuch-show-refresh-view)
390             (test-visible-output)'
391 test_expect_equal_file OUTPUT EXPECTED
392
393 test_begin_subtest "Refresh modified show buffer"
394 test_subtest_known_broken
395 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
396             (notmuch-show-toggle-message)
397             (notmuch-show-next-message)
398             (notmuch-show-toggle-message)
399             (test-visible-output "EXPECTED")
400             (notmuch-show-refresh-view)
401             (test-visible-output)'
402 test_expect_equal_file OUTPUT EXPECTED
403
404 test_done