]> git.notmuchmail.org Git - notmuch/blob - test/T440-emacs-hello.sh
dc80cc75880d59845a02e7c5b29c7b4965d7c0ce
[notmuch] / test / T440-emacs-hello.sh
1 #!/usr/bin/env bash
2
3 test_description="emacs notmuch-hello view"
4 . $(dirname "$0")/test-lib.sh || exit 1
5 . $NOTMUCH_SRCDIR/test/test-lib-emacs.sh || exit 1
6
7 EXPECTED=$NOTMUCH_SRCDIR/test/emacs.expected-output
8
9 test_require_emacs
10 add_email_corpus
11
12 test_begin_subtest "User-defined section with inbox tag"
13 test_emacs "(let ((notmuch-hello-sections
14                    (list (lambda () (notmuch-hello-insert-searches
15                                      \"Test\" '((\"inbox\" . \"tag:inbox\")))))))
16            (notmuch-hello)
17            (test-output))"
18 test_expect_equal_file $EXPECTED/notmuch-hello-new-section OUTPUT
19
20 test_begin_subtest "User-defined section with empty, hidden entry"
21 test_emacs "(let ((notmuch-hello-sections
22                    (list (lambda () (notmuch-hello-insert-searches
23                                      \"Test-with-empty\"
24                                      '((\"inbox\" . \"tag:inbox\")
25                                        (\"doesnotexist\" . \"tag:doesnotexist\"))
26                                      :hide-empty-searches t)))))
27              (notmuch-hello)
28              (test-output))"
29 test_expect_equal_file $EXPECTED/notmuch-hello-section-with-empty OUTPUT
30
31 test_begin_subtest "User-defined section, unread tag filtered out"
32 test_emacs "(let ((notmuch-hello-sections
33                    (list (lambda () (notmuch-hello-insert-tags-section
34                                      \"Test-with-filtered\"
35                                      :hide-tags '(\"unread\"))))))
36              (notmuch-hello)
37              (test-output))"
38 test_expect_equal_file $EXPECTED/notmuch-hello-section-hidden-tag OUTPUT
39
40 test_begin_subtest "User-defined section, different query for counts"
41 test_emacs "(let ((notmuch-hello-sections
42                    (list (lambda () (notmuch-hello-insert-tags-section
43                                      \"Test-with-counts\"
44                                      :filter-count \"tag:signed\")))))
45              (notmuch-hello)
46              (test-output))"
47 test_expect_equal_file $EXPECTED/notmuch-hello-section-counts OUTPUT
48
49 test_begin_subtest "Empty custom tags section"
50 test_emacs "(let* ((widget (widget-create 'notmuch-hello-tags-section))
51                    (notmuch-hello-sections (list (widget-value widget))))
52              (notmuch-hello)
53              (test-output))"
54 test_expect_equal_file $EXPECTED/notmuch-hello-empty-custom-tags-section OUTPUT
55
56 test_begin_subtest "Empty custom queries section"
57 test_emacs "(let* ((widget (widget-create 'notmuch-hello-query-section))
58                    (notmuch-hello-sections (list (widget-value widget))))
59              (notmuch-hello)
60              (test-output))"
61 test_expect_equal_file $EXPECTED/notmuch-hello-empty-custom-queries-section OUTPUT
62
63 test_begin_subtest "Column alignment for tag/queries with long names"
64 tag=a-very-long-tag # length carefully calculated for 80 characters window width
65 notmuch tag +$tag '*'
66 test_emacs '(notmuch-hello)
67             (test-output)'
68 notmuch tag -$tag '*'
69 test_expect_equal_file $EXPECTED/notmuch-hello-long-names OUTPUT
70
71 test_begin_subtest "All tags show up"
72 test_subtest_known_broken
73 tag=exclude_me
74 notmuch tag +$tag '*'
75 notmuch config set search.exclude_tags $tag
76 test_emacs '(notmuch-hello)
77             (test-output)'
78 notmuch tag -$tag '*'
79 test_expect_equal_file $EXPECTED/notmuch-hello-all-tags OUTPUT
80
81 test_done
82 test_begin_subtest "notmuch-hello with nonexistent CWD"
83 test_emacs '
84       (notmuch-hello)
85       (test-log-error
86         (let ((default-directory "/nonexistent"))
87           (notmuch-hello-update)))'
88 test_expect_equal "$(cat MESSAGES)" "COMPLETE"
89
90 test_done