aboutsummaryrefslogtreecommitdiffstats
path: root/mail-overview/test-mail-notify.sh
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-13 17:20:09 +0200
committerDanilo M. <danix@danix.xyz>2026-09-13 17:20:09 +0200
commit73539f9d3863013d8a6baebfd05da0b10b4190c7 (patch)
tree33c76aab7efde9a4478e62c1db25b530f48c3585 /mail-overview/test-mail-notify.sh
parent4ad2936cb5a4a6a44c46911ae7810bc161402dbb (diff)
downloadquickshell-73539f9d3863013d8a6baebfd05da0b10b4190c7.tar.gz
quickshell-73539f9d3863013d8a6baebfd05da0b10b4190c7.zip
feat(mail-overview): build notification bodies
Three rows of author and subject, then +N more, which bounds the height so a mailing list burst is not a wall. Markup characters are escaped because dunst renders body markup and a subject is untrusted text off the internet.
Diffstat (limited to 'mail-overview/test-mail-notify.sh')
-rwxr-xr-xmail-overview/test-mail-notify.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/mail-overview/test-mail-notify.sh b/mail-overview/test-mail-notify.sh
index 8be456c..fccf4b3 100755
--- a/mail-overview/test-mail-notify.sh
+++ b/mail-overview/test-mail-notify.sh
@@ -78,5 +78,38 @@ check "a non-account section is not an account" \
"" \
"$(parse_accounts <<<"$fixture" | awk -F'\t' '$1=="ui"{print $2}')"
+# The shape notmuch search --format=json actually returns, trimmed to the two
+# fields the body uses.
+rows_json='[
+ {"authors":"Alice Example","subject":"First subject"},
+ {"authors":"Bob Example","subject":"Second subject"},
+ {"authors":"Carol Example","subject":"Third subject"}
+]'
+
+check "a body lists author and subject per row" \
+ "Alice Example — First subject
+Bob Example — Second subject
+Carol Example — Third subject" \
+ "$(build_body "$rows_json" 3)"
+
+check "a batch bigger than the rows shown is elided" \
+ "Alice Example — First subject
+Bob Example — Second subject
+Carol Example — Third subject
++7 more" \
+ "$(build_body "$rows_json" 10)"
+
+check "markup characters are escaped, not rendered" \
+ "A &amp; B — &lt;script&gt;" \
+ "$(build_body '[{"authors":"A & B","subject":"<script>"}]' 1)"
+
+check "a missing subject says so rather than printing nothing" \
+ "Alice Example — (no subject)" \
+ "$(build_body '[{"authors":"Alice Example","subject":null}]' 1)"
+
+check "malformed json yields an empty body rather than an error" \
+ "" \
+ "$(build_body 'not json at all' 1 2>/dev/null)"
+
printf '\n%d passed, %d failed\n' "$pass" "$fail"
[[ "$fail" -eq 0 ]]