test: renamed test scripts to format T\d\d\d-name.sh
[notmuch] / test / T460-emacs-tree.sh
1 #!/usr/bin/env bash
2
3 test_description="emacs tree view interface"
4 . test-lib.sh
5
6 EXPECTED=$TEST_DIRECTORY/tree.expected-output
7
8 add_email_corpus
9
10 test_begin_subtest "Basic notmuch-tree view in emacs"
11 test_emacs '(notmuch-tree "tag:inbox")
12             (notmuch-test-wait)
13             (test-output)
14             (delete-other-windows)'
15 test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-tag-inbox
16
17 test_begin_subtest "Refreshed notmuch-tree view in emacs"
18 test_emacs '(notmuch-tree "tag:inbox")
19             (notmuch-test-wait)
20             (notmuch-tree-refresh-view)
21             (notmuch-test-wait)
22             (test-output)
23             (delete-other-windows)'
24 test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-tag-inbox
25
26 # In the following tag tests we make sure the display is updated
27 # correctly and, in a separate test, that the database is updated
28 # correctly.
29
30 test_begin_subtest "Tag message in notmuch tree view (display)"
31 test_emacs '(notmuch-tree "tag:inbox")
32             (notmuch-test-wait)
33             (forward-line)
34             (notmuch-tree-tag (list "+test_tag"))
35             (test-output)
36             (delete-other-windows)'
37 test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-tag-inbox-tagged
38
39 test_begin_subtest "Tag message in notmuch tree view (database)"
40 output=$(notmuch search --output=messages 'tag:test_tag')
41 test_expect_equal "$output" "id:877h1wv7mg.fsf@inf-8657.int-evry.fr"
42
43 test_begin_subtest "Untag message in notmuch tree view"
44 test_emacs '(notmuch-tree "tag:inbox")
45             (notmuch-test-wait)
46             (forward-line)
47             (notmuch-tree-tag (list "-test_tag"))
48             (test-output)
49             (delete-other-windows)'
50 test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-tag-inbox
51
52 test_begin_subtest "Untag message in notmuch tree view (database)"
53 output=$(notmuch search --output=messages 'tag:test_tag')
54 test_expect_equal "$output" ""
55
56 test_begin_subtest "Tag thread in notmuch tree view"
57 test_emacs '(notmuch-tree "tag:inbox")
58             (notmuch-test-wait)
59             ;; move to a sizable thread
60             (forward-line 26)
61             (notmuch-tree-tag-thread (list "+test_thread_tag"))
62             (test-output)
63             (delete-other-windows)'
64 test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-tag-inbox-thread-tagged
65
66 test_begin_subtest "Tag message in notmuch tree view (database)"
67 output=$(notmuch search --output=messages 'tag:test_thread_tag')
68 test_expect_equal "$output" \
69 "id:87ocn0qh6d.fsf@yoom.home.cworth.org
70 id:20091118005040.GA25380@dottiness.seas.harvard.edu
71 id:yunaayketfm.fsf@aiko.keithp.com
72 id:87fx8can9z.fsf@vertex.dottedmag
73 id:20091117203301.GV3165@dottiness.seas.harvard.edu
74 id:87iqd9rn3l.fsf@vertex.dottedmag
75 id:20091117190054.GU3165@dottiness.seas.harvard.edu"
76
77 test_begin_subtest "Untag thread in notmuch tree view"
78 test_emacs '(notmuch-tree "tag:inbox")
79             (notmuch-test-wait)
80             ;; move to the same sizable thread as above
81             (forward-line 26)
82             (notmuch-tree-tag-thread (list "-test_thread_tag"))
83             (test-output)
84             (delete-other-windows)'
85 test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-tag-inbox
86
87 test_begin_subtest "Untag message in notmuch tree view (database)"
88 output=$(notmuch search --output=messages 'tag:test_thread_tag')
89 test_expect_equal "$output" ""
90
91 test_begin_subtest "Navigation of notmuch-hello to search results"
92 test_emacs '(notmuch-hello)
93             (goto-char (point-min))
94             (re-search-forward "inbox")
95             (widget-button-press (1- (point)))
96             (notmuch-test-wait)
97             (notmuch-tree-from-search-current-query)
98             (notmuch-test-wait)
99             (test-output)
100             (delete-other-windows)'
101 test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-tag-inbox
102
103 test_begin_subtest "Tree view of a single thread (from search)"
104 test_emacs '(notmuch-hello)
105             (goto-char (point-min))
106             (re-search-forward "inbox")
107             (widget-button-press (1- (point)))
108             (notmuch-test-wait)
109             (notmuch-tree-from-search-thread)
110             (notmuch-test-wait)
111             (test-output)
112             (delete-other-windows)'
113 test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-single-thread
114
115 test_begin_subtest "Tree view of a single thread (from show)"
116 test_emacs '(notmuch-hello)
117             (goto-char (point-min))
118             (re-search-forward "inbox")
119             (widget-button-press (1- (point)))
120             (notmuch-test-wait)
121             (notmuch-search-show-thread)
122             (notmuch-tree-from-show-current-query)
123             (notmuch-test-wait)
124             (test-output)
125             (delete-other-windows)'
126 test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-single-thread
127
128 test_begin_subtest "Message window of tree view"
129 test_emacs '(notmuch-hello)
130             (goto-char (point-min))
131             (re-search-forward "inbox")
132             (widget-button-press (1- (point)))
133             (notmuch-test-wait)
134             (notmuch-search-next-thread)
135             (notmuch-tree-from-search-thread)
136             (notmuch-test-wait)
137             (select-window notmuch-tree-message-window)
138             (test-output)
139             (delete-other-windows)'
140 cp OUTPUT /tmp/mjwout
141 test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-show-window
142
143 test_begin_subtest "Stash id"
144 output=$(test_emacs '(notmuch-tree "id:1258498485-sup-142@elly")
145                      (notmuch-test-wait)
146                      (notmuch-show-stash-message-id)')
147 test_expect_equal "$output" "\"Stashed: id:1258498485-sup-142@elly\""
148
149 test_begin_subtest "Move to next matching message"
150 output=$(test_emacs '(notmuch-tree "from:cworth")
151                      (notmuch-test-wait)
152                      (notmuch-tree-next-matching-message)
153                      (notmuch-show-stash-message-id)')
154 test_expect_equal "$output" "\"Stashed: id:878we4qdqf.fsf@yoom.home.cworth.org\""
155
156 test_begin_subtest "Move to next thread"
157 output=$(test_emacs '(notmuch-tree "tag:inbox")
158                      (notmuch-test-wait)
159                      (forward-line 26)
160                      (notmuch-tree-next-thread)
161                      (notmuch-show-stash-message-id)')
162 test_expect_equal "$output" "\"Stashed: id:1258471718-6781-1-git-send-email-dottedmag@dottedmag.net\""
163
164 test_begin_subtest "Move to previous thread"
165 output=$(test_emacs '(notmuch-tree "tag:inbox")
166                      (notmuch-test-wait)
167                      (forward-line 26)
168                      (notmuch-tree-prev-thread)
169                      (notmuch-show-stash-message-id)')
170 test_expect_equal "$output" "\"Stashed: id:20091117190054.GU3165@dottiness.seas.harvard.edu\""
171
172 test_begin_subtest "Move to previous previous thread"
173 output=$(test_emacs '(notmuch-tree "tag:inbox")
174                      (notmuch-test-wait)
175                      (forward-line 26)
176                      (notmuch-tree-prev-thread)
177                      (notmuch-tree-prev-thread)
178                      (notmuch-show-stash-message-id)')
179 test_expect_equal "$output" "\"Stashed: id:1258493565-13508-1-git-send-email-keithp@keithp.com\""
180
181 test_done