#!/usr/bin/env bash
-# Note: do not use `setq' for setting variables in Emacs tests because
-# it affects other tests that may run in the same Emacs instance. Use
-# `let' instead so the scope of the changed variables is limited to a
-# single test.
-
test_description="emacs interface"
. test-lib.sh
-EXPECTED=../emacs.expected-output
+EXPECTED=$TEST_DIRECTORY/emacs.expected-output
add_email_corpus
test_begin_subtest "Save attachment from within emacs using notmuch-show-save-attachments"
# save as archive to test that Emacs does not re-compress .gz
-echo ./attachment1.gz |
-test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
- (notmuch-show-save-attachments)' > /dev/null 2>&1
+test_emacs '(let ((standard-input "\"attachment1.gz\""))
+ (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
+ (notmuch-show-save-attachments))' > /dev/null 2>&1
test_expect_equal_file attachment1.gz "$EXPECTED/attachment"
test_begin_subtest "Save attachment from within emacs using notmuch-show-save-part"
# save as archive to test that Emacs does not re-compress .gz
-echo ./attachment2.gz |
-test_emacs '(notmuch-show-save-part "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com" 5)' > /dev/null 2>&1
+test_emacs '(let ((standard-input "\"attachment2.gz\""))
+ (notmuch-show-save-part "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com" 5))' > /dev/null 2>&1
test_expect_equal_file attachment2.gz "$EXPECTED/attachment"
test_begin_subtest "View raw message within emacs"
(test-visible-output)'
test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
+test_begin_subtest 'Hiding message following HTML part'
+test_subtest_known_broken
+id='html-message@notmuchmail.org'
+emacs_deliver_message \
+ 'HTML message' \
+ '' \
+ "(message-goto-eoh)
+ (insert \"Message-ID: <$id>\n\")
+ (message-goto-body)
+ (mml-insert-part \"text/html\")
+ (insert \"<body>This is a test HTML message</body>\")"
+emacs_deliver_message \
+ 'Reply to HTML message' \
+ 'This is a reply to the test HTML message' \
+ "(message-goto-eoh)
+ (insert \"In-Reply-To: <$id>\n\")"
+test_emacs "(notmuch-show \"id:$id\") \
+ (notmuch-show-next-message) \
+ (command-execute (key-binding (kbd \"RET\"))) \
+ (test-visible-output)"
+test_emacs "(notmuch-show \"id:$id\") \
+ (notmuch-show-next-message) \
+ (notmuch-show-toggle-message) \
+ (test-visible-output \"EXPECTED\")"
+test_expect_equal_file OUTPUT EXPECTED
+
test_done