]> git.notmuchmail.org Git - notmuch/blob - test/emacs
62eaedba55fbd7a08a93076d78fb80468dd5f0e8
[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 "Basic notmuch-show view in emacs default indentation"
54 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
55 test_emacs "(let ((notmuch-show-indent-messages-width 1))
56               (notmuch-show \"$maildir_storage_thread\")
57               (test-output))"
58 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
59
60 test_begin_subtest "Basic notmuch-show view in emacs without indentation"
61 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
62 test_emacs "(let ((notmuch-show-indent-messages-width 0))
63               (notmuch-show \"$maildir_storage_thread\")
64               (test-output))"
65 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage-without-indentation
66
67 test_begin_subtest "Basic notmuch-show view in emacs with fourfold indentation"
68 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
69 test_emacs "(let ((notmuch-show-indent-messages-width 4))
70               (notmuch-show \"$maildir_storage_thread\")
71               (test-output))"
72 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage-with-fourfold-indentation
73
74 test_begin_subtest "notmuch-show for message with invalid From"
75 add_message "[subject]=\"message-with-invalid-from\"" \
76             "[from]=\"\\\"Invalid \\\" From\\\" <test_suite@notmuchmail.org>\""
77 thread=$(notmuch search --output=threads subject:message-with-invalid-from)
78 test_emacs "(notmuch-show \"$thread\")
79             (test-output)"
80 cat <<EOF >EXPECTED
81 "Invalid " (2001-01-05) (inbox)
82 Subject: message-with-invalid-from
83 To: Notmuch Test Suite <test_suite@notmuchmail.org>
84 Date: Fri, 05 Jan 2001 15:43:57 +0000
85
86 This is just a test message (#1)
87 EOF
88 test_expect_equal_file OUTPUT EXPECTED
89
90 test_begin_subtest "Navigation of notmuch-search to thread view"
91 test_emacs '(notmuch-search "tag:inbox")
92             (notmuch-test-wait)
93             (goto-char (point-min))
94             (re-search-forward "Working with Maildir")
95             (notmuch-search-show-thread)
96             (notmuch-test-wait)
97             (test-output)'
98 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
99
100 test_begin_subtest "Add tag from search view"
101 os_x_darwin_thread=$(notmuch search --output=threads id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com)
102 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
103             (notmuch-test-wait)
104             (execute-kbd-macro \"+tag-from-search-view\")"
105 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
106 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)"
107
108 test_begin_subtest "Remove tag from search view"
109 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
110             (notmuch-test-wait)
111             (execute-kbd-macro \"-tag-from-search-view\")"
112 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
113 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)"
114
115 test_begin_subtest "Add tag from notmuch-show view"
116 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
117             (execute-kbd-macro \"+tag-from-show-view\")"
118 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
119 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)"
120
121 test_begin_subtest "Remove tag from notmuch-show view"
122 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
123             (execute-kbd-macro \"-tag-from-show-view\")"
124 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
125 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)"
126
127 test_begin_subtest "Message with .. in Message-Id:"
128 add_message [id]=123..456@example '[subject]="Message with .. in Message-Id"'
129 test_emacs '(notmuch-search "id:\"123..456@example\"")
130             (notmuch-test-wait)
131             (execute-kbd-macro "+search-add")
132             (execute-kbd-macro "+search-remove")
133             (execute-kbd-macro "-search-remove")
134             (notmuch-show "id:\"123..456@example\"")
135             (notmuch-test-wait)
136             (execute-kbd-macro "+show-add")
137             (execute-kbd-macro "+show-remove")
138             (execute-kbd-macro "-show-remove")'
139 output=$(notmuch search 'id:"123..456@example"' | notmuch_search_sanitize)
140 test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Message with .. in Message-Id (inbox search-add show-add)"
141
142 test_begin_subtest "Message with quote in Message-Id:"
143 test_subtest_known_broken
144 add_message '[id]="\"quote\"@example"' '[subject]="Message with quote in Message-Id"'
145 test_emacs '(notmuch-search "subject:\"Message with quote\"")
146             (notmuch-test-wait)
147             (execute-kbd-macro "+search-add")
148             (notmuch-search-show-thread)
149             (notmuch-test-wait)
150             (execute-kbd-macro "+show-add")'
151 output=$(notmuch search 'id:"""quote""@example"' | notmuch_search_sanitize)
152 test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Message with quote in Message-Id (inbox search-add show-add)"
153
154 test_begin_subtest "Sending a message via (fake) SMTP"
155 emacs_deliver_message \
156     'Testing message sent via SMTP' \
157     'This is a test that messages are sent via SMTP' \
158     '(message-goto-to)
159      (kill-whole-line)
160      (insert "To: user@example.com\n")'
161 sed \
162     -e s',^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' \
163     -e s',^Message-ID: <.*>$,Message-ID: <XXX>,' < sent_message >OUTPUT
164 cat <<EOF >EXPECTED
165 From: Notmuch Test Suite <test_suite@notmuchmail.org>
166 To: user@example.com
167 Subject: Testing message sent via SMTP
168 Date: 01 Jan 2000 12:00:00 -0000
169 User-Agent: Notmuch/XXX Emacs/XXX
170 Message-ID: <XXX>
171 MIME-Version: 1.0
172 Content-Type: text/plain; charset=us-ascii
173
174 This is a test that messages are sent via SMTP
175 EOF
176 test_expect_equal_file OUTPUT EXPECTED
177
178 test_begin_subtest "Verify that sent messages are saved/searchable (via FCC)"
179 notmuch new > /dev/null
180 output=$(notmuch search 'subject:"testing message sent via SMTP"' | notmuch_search_sanitize)
181 test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; Testing message sent via SMTP (inbox)"
182
183 test_begin_subtest "notmuch-fcc-dirs set to nil"
184 test_emacs "(let ((notmuch-fcc-dirs nil))
185               (notmuch-mua-mail)
186               (test-output))"
187 cat <<EOF >EXPECTED
188 From: Notmuch Test Suite <test_suite@notmuchmail.org>
189 To: 
190 Subject: 
191 --text follows this line--
192 EOF
193 test_expect_equal_file OUTPUT EXPECTED
194
195 # Make another FCC maildir specific for the next test
196 mkdir -p mail/sent-string/cur
197 mkdir -p mail/sent-string/new
198 mkdir -p mail/sent-string/tmp
199
200 test_begin_subtest "notmuch-fcc-dirs set to a string"
201 test_emacs "(let ((notmuch-fcc-dirs \"sent-string\"))
202               (notmuch-mua-mail)
203               (test-output))"
204 cat <<EOF >EXPECTED
205 From: Notmuch Test Suite <test_suite@notmuchmail.org>
206 To: 
207 Subject: 
208 Fcc: ${MAIL_DIR}/sent-string
209 --text follows this line--
210 EOF
211 test_expect_equal_file OUTPUT EXPECTED
212
213 # Make more FCC maildirs specific for the next test
214 mkdir -p mail/sent-list-match/cur
215 mkdir -p mail/sent-list-match/new
216 mkdir -p mail/sent-list-match/tmp
217 mkdir -p mail/failure/cur
218 mkdir -p mail/failure/new
219 mkdir -p mail/failure/tmp
220
221 test_begin_subtest "notmuch-fcc-dirs set to a list (with match)"
222 test_emacs "(let ((notmuch-fcc-dirs
223                    '((\"notmuchmail.org\" . \"sent-list-match\")
224                      (\".*\" . \"failure\"))))
225               (notmuch-mua-mail)
226               (test-output))"
227 cat <<EOF >EXPECTED
228 From: Notmuch Test Suite <test_suite@notmuchmail.org>
229 To: 
230 Subject: 
231 Fcc: ${MAIL_DIR}/sent-list-match
232 --text follows this line--
233 EOF
234 test_expect_equal_file OUTPUT EXPECTED
235
236 # Make another FCC maildir specific for the next test
237 mkdir -p mail/sent-list-catch-all/cur
238 mkdir -p mail/sent-list-catch-all/new
239 mkdir -p mail/sent-list-catch-all/tmp
240
241 test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)"
242 test_emacs "(let ((notmuch-fcc-dirs
243                    '((\"example.com\" . \"failure\")
244                      (\".*\" . \"sent-list-catch-all\"))))
245               (notmuch-mua-mail)
246               (test-output))"
247 cat <<EOF >EXPECTED
248 From: Notmuch Test Suite <test_suite@notmuchmail.org>
249 To: 
250 Subject: 
251 Fcc: ${MAIL_DIR}/sent-list-catch-all
252 --text follows this line--
253 EOF
254 test_expect_equal_file OUTPUT EXPECTED
255
256 test_begin_subtest "notmuch-fcc-dirs set to a list (no match)"
257 test_emacs "(let ((notmuch-fcc-dirs
258                    '((\"example.com\" . \"failure\")
259                      (\"nomatchhere.net\" . \"failure\"))))
260               (notmuch-mua-mail)
261               (test-output))"
262 cat <<EOF >EXPECTED
263 From: Notmuch Test Suite <test_suite@notmuchmail.org>
264 To: 
265 Subject: 
266 --text follows this line--
267 EOF
268 test_expect_equal_file OUTPUT EXPECTED
269
270 test_begin_subtest "Reply within emacs"
271 test_emacs '(notmuch-search "subject:\"testing message sent via SMTP\"")
272             (notmuch-test-wait)
273             (notmuch-search-reply-to-thread)
274             (test-output)'
275 sed -i -e 's/^In-Reply-To: <.*>$/In-Reply-To: <XXX>/' OUTPUT
276 cat <<EOF >EXPECTED
277 From: Notmuch Test Suite <test_suite@notmuchmail.org>
278 To: user@example.com
279 Subject: Re: Testing message sent via SMTP
280 In-Reply-To: <XXX>
281 Fcc: ${MAIL_DIR}/sent
282 --text follows this line--
283 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
284
285 > This is a test that messages are sent via SMTP
286 EOF
287 test_expect_equal_file OUTPUT EXPECTED
288
289 test_begin_subtest "Reply within emacs to a multipart/mixed message"
290 test_emacs '(notmuch-show "id:20091118002059.067214ed@hikari")
291                 (notmuch-show-reply)
292                 (test-output)'
293 cat <<EOF >EXPECTED
294 From: Notmuch Test Suite <test_suite@notmuchmail.org>
295 To: Adrian Perez de Castro <aperez@igalia.com>, notmuch@notmuchmail.org
296 Subject: Re: [notmuch] Introducing myself
297 In-Reply-To: <20091118002059.067214ed@hikari>
298 Fcc: ${MAIL_DIR}/sent
299 --text follows this line--
300 Adrian Perez de Castro <aperez@igalia.com> writes:
301
302 > Hello to all,
303 >
304 > I have just heard about Not Much today in some random Linux-related news
305 > site (LWN?), my name is Adrian Perez and I work as systems administrator
306 > (although I can do some code as well :P). I have always thought that the
307 > ideas behind Sup were great, but after some time using it, I got tired of
308 > the oddities that it has. I also do not like doing things like having to
309 > install Ruby just for reading and sorting mails. Some time ago I thought
310 > about doing something like Not Much and in fact I played a bit with the
311 > Python+Xapian and the Python+Whoosh combinations, because I find relaxing
312 > to code things in Python when I am not working and also it is installed
313 > by default on most distribution. I got to have some mailboxes indexed and
314 > basic searching working a couple of months ago. Lately I have been very
315 > busy and had no time for coding, and them... boom! Not Much appears -- and
316 > it is almost exactly what I was trying to do, but faster. I have been
317 > playing a bit with Not Much today, and I think it has potential.
318 >
319 > Also, I would like to share one idea I had in mind, that you might find
320 > interesting: One thing I have found very annoying is having to re-tag my
321 > mail when the indexes get b0rked (it happened a couple of times to me while
322 > using Sup), so I was planning to mails as read/unread and adding the tags
323 > not just to the index, but to the mail text itself, e.g. by adding a
324 > "X-Tags" header field or by reusing the "Keywords" one. This way, the index
325 > could be totally recreated by re-reading the mail directories, and this
326 > would also allow to a tools like OfflineIMAP [1] to get the mails into a
327 > local maildir, tagging and indexing the mails with the e-mail reader and
328 > then syncing back the messages with the "X-Tags" header to the IMAP server.
329 > This would allow to use the mail reader from a different computer and still
330 > have everything tagged finely.
331 >
332 > Best regards,
333 >
334 >
335 > ---
336 > [1] http://software.complete.org/software/projects/show/offlineimap
337 >
338 > -- 
339 > Adrian Perez de Castro <aperez@igalia.com>
340 > Igalia - Free Software Engineering
341 > _______________________________________________
342 > notmuch mailing list
343 > notmuch@notmuchmail.org
344 > http://notmuchmail.org/mailman/listinfo/notmuch
345 EOF
346 test_expect_equal_file OUTPUT EXPECTED
347
348 test_begin_subtest "Reply within emacs to a multipart/alternative message"
349 test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
350                 (notmuch-show-reply)
351                 (test-output)'
352 cat <<EOF >EXPECTED
353 From: Notmuch Test Suite <test_suite@notmuchmail.org>
354 To: Alex Botero-Lowry <alex.boterolowry@gmail.com>, notmuch@notmuchmail.org
355 Subject: Re: [notmuch] preliminary FreeBSD support
356 In-Reply-To: <cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com>
357 Fcc: ${MAIL_DIR}/sent
358 --text follows this line--
359 Alex Botero-Lowry <alex.boterolowry@gmail.com> writes:
360
361 > I saw the announcement this morning, and was very excited, as I had been
362 > hoping sup would be turned into a library,
363 > since I like the concept more than the UI (I'd rather an emacs interface).
364 >
365 > I did a preliminary compile which worked out fine, but
366 > sysconf(_SC_SC_GETPW_R_SIZE_MAX) returns -1 on
367 > FreeBSD, so notmuch_config_open segfaulted.
368 >
369 > Attached is a patch that supplies a default buffer size of 64 in cases where
370 > -1 is returned.
371 >
372 > http://www.opengroup.org/austin/docs/austin_328.txt - seems to indicate this
373 > is acceptable behavior,
374 > and http://mail-index.netbsd.org/pkgsrc-bugs/2006/06/07/msg016808.htmlspecifically
375 > uses 64 as the
376 > buffer size.
377 > _______________________________________________
378 > notmuch mailing list
379 > notmuch@notmuchmail.org
380 > http://notmuchmail.org/mailman/listinfo/notmuch
381 EOF
382 test_expect_equal_file OUTPUT EXPECTED
383
384 test_begin_subtest "Quote MML tags in reply"
385 message_id='test-emacs-mml-quoting@message.id'
386 add_message [id]="$message_id" \
387             "[subject]='$test_subtest_name'" \
388             '[body]="<#part disposition=inline>"'
389 test_emacs "(notmuch-show \"id:$message_id\")
390               (notmuch-show-reply)
391               (test-output)"
392 cat <<EOF >EXPECTED
393 From: Notmuch Test Suite <test_suite@notmuchmail.org>
394 To: 
395 Subject: Re: Quote MML tags in reply
396 In-Reply-To: <test-emacs-mml-quoting@message.id>
397 Fcc: ${MAIL_DIR}/sent
398 --text follows this line--
399 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
400
401 > <#!part disposition=inline>
402 EOF
403 test_expect_equal_file OUTPUT EXPECTED
404
405 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-attachments"
406 # save as archive to test that Emacs does not re-compress .gz
407 test_emacs '(let ((standard-input "\"attachment1.gz\""))
408               (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
409               (notmuch-show-save-attachments))'
410 test_expect_equal_file attachment1.gz "$EXPECTED/attachment"
411
412 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-part"
413 # save as archive to test that Emacs does not re-compress .gz
414 test_emacs '(let ((standard-input "\"attachment2.gz\""))
415               (notmuch-show-save-part "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com" 5))'
416 test_expect_equal_file attachment2.gz "$EXPECTED/attachment"
417
418 test_begin_subtest "View raw message within emacs"
419 test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
420             (notmuch-show-view-raw-message)
421             (test-output)'
422 test_expect_equal_file OUTPUT $EXPECTED/raw-message-cf0c4d-52ad0a
423
424 test_begin_subtest "Hiding/showing signature in notmuch-show view"
425 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
426 test_emacs "(notmuch-show \"$maildir_storage_thread\")
427             (search-forward \"Click/Enter to show.\")
428             (button-activate (button-at (point)))
429             (search-backward \"Click/Enter to hide.\")
430             (button-activate (button-at (point)))
431             (test-output)"
432 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
433
434 test_begin_subtest "Detection and hiding of top-post quoting of message"
435 add_message '[subject]="The problem with top-posting"' \
436             [id]=top-post-target \
437             '[body]="A: Because it messes up the order in which people normally read text.
438 Q: Why is top-posting such a bad thing?
439 A: Top-posting.
440 Q: What is the most annoying thing in e-mail?"'
441 add_message '[from]="Top Poster <top@poster.com>"' \
442             [in-reply-to]=top-post-target \
443             [references]=top-post-target \
444             '[subject]="Re: The problem with top-posting"' \
445             '[body]="Thanks for the advice! I will be sure to put it to good use.
446
447 -Top Poster
448
449 ----- Original Message -----
450 From: Notmuch Test Suite <test_suite@notmuchmail.org>
451 To: Notmuch Test Suite <test_suite@notmuchmai.org>
452 Sent: Fri, 05 Jan 2001 15:43:57 +0000
453 Subject: The problem with top-posting
454
455 Q: Why is top-posting such a bad thing?
456 A: Top-posting.
457 Q: What is the most annoying thing in e-mail?"'
458 test_emacs "(notmuch-show \"top-posting\")
459             (test-visible-output)"
460 echo "Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
461 Subject: The problem with top-posting
462 To: Notmuch Test Suite <test_suite@notmuchmail.org>
463 Date: Fri, 05 Jan 2001 15:43:57 +0000
464
465 A: Because it messes up the order in which people normally read text.
466 Q: Why is top-posting such a bad thing?
467 A: Top-posting.
468 Q: What is the most annoying thing in e-mail?
469 Top Poster <top@poster.com> (2001-01-05) (inbox unread)
470 Subject: Re: The problem with top-posting
471 To: Notmuch Test Suite <test_suite@notmuchmail.org>
472 Date: Fri, 05 Jan 2001 15:43:57 +0000
473
474 Thanks for the advice! I will be sure to put it to good use.
475
476 -Top Poster
477
478 [ 9-line hidden original message. Click/Enter to show. ]" > EXPECTED
479 test_expect_equal_file OUTPUT EXPECTED
480
481 test_begin_subtest "Hiding message in notmuch-show view"
482 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
483             (notmuch-show-toggle-message)
484             (test-visible-output)'
485 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
486
487 test_begin_subtest "Hiding message with visible citation in notmuch-show view"
488 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
489             (search-forward "Click/Enter to show.")
490             (button-activate (button-at (point)))
491             (notmuch-show-toggle-message)
492             (test-visible-output)'
493 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
494
495 test_begin_subtest "Stashing in notmuch-show"
496 add_message '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' \
497     '[from]="Some One <someone@somewhere.org>"' \
498     '[to]="Some One Else <notsomeone@somewhere.org>"' \
499     '[cc]="Notmuch <notmuch@notmuchmail.org>"' \
500     '[subject]="Stash my stashables"' \
501     '[id]="bought"' \
502     '[body]="Unable to stash body. Where did you get it in the first place?!?"'
503 notmuch tag +stashtest id:${gen_msg_id}
504 test_emacs '(notmuch-show "id:\"bought\"")
505         (notmuch-show-stash-date)
506         (notmuch-show-stash-from)
507         (notmuch-show-stash-to)
508         (notmuch-show-stash-cc)
509         (notmuch-show-stash-subject)
510         (notmuch-show-stash-message-id)
511         (notmuch-show-stash-message-id-stripped)
512         (notmuch-show-stash-tags)
513         (notmuch-show-stash-filename)
514         (notmuch-show-stash-mlarchive-link "Gmane")
515         (notmuch-show-stash-mlarchive-link "MARC")
516         (notmuch-show-stash-mlarchive-link "Mail Archive, The")
517         (switch-to-buffer
518           (generate-new-buffer "*test-stashing*"))
519         (dotimes (i 12)
520           (yank)
521           (insert "\n")
522           (rotate-yank-pointer 1))
523         (reverse-region (point-min) (point-max))
524             (test-output)'
525 cat <<EOF >EXPECTED
526 Sat, 01 Jan 2000 12:00:00 +0000
527 Some One <someone@somewhere.org>
528 Some One Else <notsomeone@somewhere.org>
529 Notmuch <notmuch@notmuchmail.org>
530 Stash my stashables
531 id:"bought"
532 bought
533 inbox,stashtest
534 ${gen_msg_filename}
535 http://mid.gmane.org/bought
536 http://marc.info/?i=bought
537 http://mail-archive.com/search?l=mid&q=bought
538 EOF
539 test_expect_equal_file OUTPUT EXPECTED
540
541 test_begin_subtest "Stashing in notmuch-search"
542 test_emacs '(notmuch-search "id:\"bought\"")
543         (notmuch-test-wait)
544         (notmuch-search-stash-thread-id)
545         (switch-to-buffer
546           (generate-new-buffer "*test-stashing*"))
547         (yank)
548             (test-output)'
549 sed -i -e 's/^thread:.*$/thread:XXX/' OUTPUT
550 test_expect_equal "$(cat OUTPUT)" "thread:XXX"
551
552 test_begin_subtest 'notmuch-show-advance-and-archive with invisible signature'
553 message1='id:20091118010116.GC25380@dottiness.seas.harvard.edu'
554 message2='id:1258491078-29658-1-git-send-email-dottedmag@dottedmag.net'
555 test_emacs "(notmuch-search \"$message1 or $message2\")
556             (notmuch-test-wait)
557             (notmuch-search-show-thread)
558             (goto-char (point-max))
559             (redisplay)
560             (notmuch-show-advance-and-archive)
561             (test-output)"
562 test_emacs "(notmuch-show \"$message2\")
563             (test-output \"EXPECTED\")"
564 test_expect_equal_file OUTPUT EXPECTED
565
566 test_begin_subtest "Refresh show buffer"
567 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
568             (test-visible-output "EXPECTED")
569             (notmuch-show-refresh-view)
570             (test-visible-output)'
571 test_expect_equal_file OUTPUT EXPECTED
572
573 test_begin_subtest "Refresh modified show buffer"
574 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
575             (notmuch-show-toggle-message)
576             (notmuch-show-next-message)
577             (notmuch-show-toggle-message)
578             (test-visible-output "EXPECTED")
579             (notmuch-show-refresh-view)
580             (test-visible-output)'
581 test_expect_equal_file OUTPUT EXPECTED
582
583 test_begin_subtest "Do not call notmuch for non-inlinable application/mpeg parts"
584 id='message-with-application/mpeg-attachment@notmuchmail.org'
585 emacs_deliver_message \
586     'Message with application/mpeg attachment' \
587     '' \
588     "(message-goto-eoh)
589      (insert \"Message-ID: <$id>\n\")
590      (message-goto-body)
591      (mml-insert-part \"application/mpeg\")
592      (insert \"a fake mp3 file\")"
593 notmuch_counter_reset
594 test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
595               (notmuch-show \"id:$id\"))"
596 test_expect_equal $(notmuch_counter_value) 1
597
598 test_begin_subtest "Do not call notmuch for non-inlinable audio/mpeg parts"
599 id='message-with-audio/mpeg-attachment@notmuchmail.org'
600 emacs_deliver_message \
601     'Message with audio/mpeg attachment' \
602     '' \
603     "(message-goto-eoh)
604      (insert \"Message-ID: <$id>\n\")
605      (message-goto-body)
606      (mml-insert-part \"audio/mpeg\")
607      (insert \"a fake mp3 file\")"
608 notmuch_counter_reset
609 test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
610               (notmuch-show \"id:$id\"))"
611 test_expect_equal $(notmuch_counter_value) 1
612
613 test_begin_subtest "notmuch-hello-mode hook is called"
614 counter=$(test_emacs \
615     '(let ((notmuch-hello-mode-hook-counter 0))
616        (kill-buffer "*notmuch-hello*")
617        (notmuch-hello)
618        notmuch-hello-mode-hook-counter)'
619 )
620 test_expect_equal "$counter" 1
621
622 test_begin_subtest "notmuch-hello-mode hook is not called on updates"
623 counter=$(test_emacs \
624     '(let ((notmuch-hello-mode-hook-counter 0))
625        (kill-buffer "*notmuch-hello*")
626        (notmuch-hello)
627        (notmuch-hello-update)
628        notmuch-hello-mode-hook-counter)'
629 )
630 test_expect_equal "$counter" 1
631
632 test_begin_subtest "notmuch-hello-refresh hook is called"
633 counter=$(test_emacs \
634     '(let ((notmuch-hello-refresh-hook-counter 0))
635        (kill-buffer "*notmuch-hello*")
636        (notmuch-hello)
637        notmuch-hello-refresh-hook-counter)'
638 )
639 test_expect_equal "$counter" 1
640
641 test_begin_subtest "notmuch-hello-refresh hook is called on updates"
642 counter=$(test_emacs \
643     '(let ((notmuch-hello-refresh-hook-counter 0))
644        (kill-buffer "*notmuch-hello*")
645        (notmuch-hello)
646        (notmuch-hello-update)
647        notmuch-hello-refresh-hook-counter)'
648 )
649 test_expect_equal "$counter" 2
650
651 test_done