]> git.notmuchmail.org Git - notmuch/blob - contrib/notmuch-pick/test/emacs-pick
pick: rename test outputs from pick to tree
[notmuch] / contrib / notmuch-pick / test / emacs-pick
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 test_begin_subtest "Do we have emacs"
10 test_emacs '(insert "hello\n")
11             (test-output)'
12 cat <<EOF >EXPECTED
13 hello
14 EOF
15 test_expect_equal_file OUTPUT EXPECTED
16
17 test_begin_subtest "Basic notmuch-tree view in emacs"
18 test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
19             (require (quote notmuch-tree))
20             (notmuch-tree "tag:inbox")
21             (notmuch-test-wait)
22             (test-output)
23             (delete-other-windows)'
24 test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-tag-inbox
25
26 test_begin_subtest "Refreshed notmuch-tree view in emacs"
27 test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
28             (require (quote notmuch-tree))
29             (notmuch-tree "tag:inbox")
30             (notmuch-test-wait)
31             (notmuch-tree-refresh-view)
32             (notmuch-test-wait)
33             (test-output)
34             (delete-other-windows)'
35 test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-tag-inbox
36
37 # In the following tag tests we make sure the display is updated
38 # correctly and, in a separate test, that the database is updated
39 # correctly.
40
41 test_begin_subtest "Tag message in notmuch tree view (display)"
42 test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
43             (require (quote notmuch-tree))
44             (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-tagged
51
52 test_begin_subtest "Tag message in notmuch tree view (database)"
53 output=$(notmuch search --output=messages 'tag:test_tag')
54 test_expect_equal "$output" "id:877h1wv7mg.fsf@inf-8657.int-evry.fr"
55
56 test_begin_subtest "Untag message in notmuch tree view"
57 test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
58             (require (quote notmuch-tree))
59             (notmuch-tree "tag:inbox")
60             (notmuch-test-wait)
61             (forward-line)
62             (notmuch-tree-tag (list "-test_tag"))
63             (test-output)
64             (delete-other-windows)'
65 test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-tag-inbox
66
67 test_begin_subtest "Untag message in notmuch tree view (database)"
68 output=$(notmuch search --output=messages 'tag:test_tag')
69 test_expect_equal "$output" ""
70
71 test_begin_subtest "Tag thread in notmuch tree view"
72 test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
73             (require (quote notmuch-tree))
74             (notmuch-tree "tag:inbox")
75             (notmuch-test-wait)
76             ;; move to a sizable thread
77             (forward-line 26)
78             (notmuch-tree-tag-thread (list "+test_thread_tag"))
79             (test-output)
80             (delete-other-windows)'
81 test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-tag-inbox-thread-tagged
82
83 test_begin_subtest "Tag message in notmuch tree view (database)"
84 output=$(notmuch search --output=messages 'tag:test_thread_tag')
85 test_expect_equal "$output" \
86 "id:87ocn0qh6d.fsf@yoom.home.cworth.org
87 id:20091118005040.GA25380@dottiness.seas.harvard.edu
88 id:yunaayketfm.fsf@aiko.keithp.com
89 id:87fx8can9z.fsf@vertex.dottedmag
90 id:20091117203301.GV3165@dottiness.seas.harvard.edu
91 id:87iqd9rn3l.fsf@vertex.dottedmag
92 id:20091117190054.GU3165@dottiness.seas.harvard.edu"
93
94 test_begin_subtest "Untag thread in notmuch tree view"
95 test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
96             (require (quote notmuch-tree))
97             (notmuch-tree "tag:inbox")
98             (notmuch-test-wait)
99             ;; move to the same sizable thread as above
100             (forward-line 26)
101             (notmuch-tree-tag-thread (list "-test_thread_tag"))
102             (test-output)
103             (delete-other-windows)'
104 test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-tag-inbox
105
106 test_begin_subtest "Untag message in notmuch tree view (database)"
107 output=$(notmuch search --output=messages 'tag:test_thread_tag')
108 test_expect_equal "$output" ""
109
110 test_begin_subtest "Navigation of notmuch-hello to search results"
111 test_emacs '(notmuch-hello)
112             (goto-char (point-min))
113             (re-search-forward "inbox")
114             (widget-button-press (1- (point)))
115             (notmuch-test-wait)
116             (notmuch-tree-from-search-current-query)
117             (notmuch-test-wait)
118             (test-output)
119             (delete-other-windows)'
120 test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-tag-inbox
121
122 test_begin_subtest "Tree view of a single thread (from search)"
123 test_emacs '(notmuch-hello)
124             (goto-char (point-min))
125             (re-search-forward "inbox")
126             (widget-button-press (1- (point)))
127             (notmuch-test-wait)
128             (notmuch-tree-from-search-thread)
129             (notmuch-test-wait)
130             (test-output)
131             (delete-other-windows)'
132 test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-single-thread
133
134 test_begin_subtest "Tree view of a single thread (from show)"
135 test_emacs '(notmuch-hello)
136             (goto-char (point-min))
137             (re-search-forward "inbox")
138             (widget-button-press (1- (point)))
139             (notmuch-test-wait)
140             (notmuch-search-show-thread)
141             (notmuch-tree-from-show-current-query)
142             (notmuch-test-wait)
143             (test-output)
144             (delete-other-windows)'
145 test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-single-thread
146
147 test_begin_subtest "Message window of tree view"
148 test_emacs '(notmuch-hello)
149             (goto-char (point-min))
150             (re-search-forward "inbox")
151             (widget-button-press (1- (point)))
152             (notmuch-test-wait)
153             (notmuch-search-next-thread)
154             (notmuch-tree-from-search-thread)
155             (notmuch-test-wait)
156             (select-window notmuch-tree-message-window)
157             (test-output)
158             (delete-other-windows)'
159 cp OUTPUT /tmp/mjwout
160 test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-show-window
161
162 test_begin_subtest "Stash id"
163 output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
164                      (require (quote notmuch-tree))
165                      (notmuch-tree "id:1258498485-sup-142@elly")
166                      (notmuch-test-wait)
167                      (notmuch-show-stash-message-id)')
168 test_expect_equal "$output" "\"Stashed: id:1258498485-sup-142@elly\""
169
170 test_begin_subtest "Move to next matching message"
171 output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
172                      (require (quote notmuch-tree))
173                      (notmuch-tree "from:cworth")
174                      (notmuch-test-wait)
175                      (notmuch-tree-next-matching-message)
176                      (notmuch-show-stash-message-id)')
177 test_expect_equal "$output" "\"Stashed: id:878we4qdqf.fsf@yoom.home.cworth.org\""
178
179 test_begin_subtest "Move to next thread"
180 output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
181                      (require (quote notmuch-tree))
182                      (notmuch-tree "tag:inbox")
183                      (notmuch-test-wait)
184                      (forward-line 26)
185                      (notmuch-tree-next-thread)
186                      (notmuch-show-stash-message-id)')
187 test_expect_equal "$output" "\"Stashed: id:1258471718-6781-1-git-send-email-dottedmag@dottedmag.net\""
188
189 test_begin_subtest "Move to previous thread"
190 output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
191                      (require (quote notmuch-tree))
192                      (notmuch-tree "tag:inbox")
193                      (notmuch-test-wait)
194                      (forward-line 26)
195                      (notmuch-tree-prev-thread)
196                      (notmuch-show-stash-message-id)')
197 test_expect_equal "$output" "\"Stashed: id:20091117190054.GU3165@dottiness.seas.harvard.edu\""
198
199 test_begin_subtest "Move to previous previous thread"
200 output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'")
201                      (require (quote notmuch-tree))
202                      (notmuch-tree "tag:inbox")
203                      (notmuch-test-wait)
204                      (forward-line 26)
205                      (notmuch-tree-prev-thread)
206                      (notmuch-tree-prev-thread)
207                      (notmuch-show-stash-message-id)')
208 test_expect_equal "$output" "\"Stashed: id:1258493565-13508-1-git-send-email-keithp@keithp.com\""
209
210 test_done