aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-26 16:22:49 +0200
committerDanilo M. <danix@danix.xyz>2026-08-26 16:22:49 +0200
commit496e174e65c06563aff426bdbbeeba006102e89d (patch)
treec43c434598fbfca36055a1cd7487fecb1dffce5f /tests
parent409faeadf013952420963fa1b740d44526d8a95e (diff)
downloadqtmaildir-496e174e65c06563aff426bdbbeeba006102e89d.tar.gz
qtmaildir-496e174e65c06563aff426bdbbeeba006102e89d.zip
feat: propose business senders from newly synced mail
Diffstat (limited to 'tests')
-rw-r--r--tests/test_notmuchworker.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test_notmuchworker.cpp b/tests/test_notmuchworker.cpp
index 2d19da5..4fa8629 100644
--- a/tests/test_notmuchworker.cpp
+++ b/tests/test_notmuchworker.cpp
@@ -66,6 +66,7 @@ private slots:
void aQueryCarriesEachThreadsFirstMessageId();
void aSentQueryCarriesTheMatchedMessageNotTheThreadsFirst();
void queryCarriesTheFirstMessageSender();
+ void sendersAreCountedForTheCandidateList();
void loadThreadTreeReportsReplyDepth();
void loadThreadTreeCarriesTheFactsARowNeeds();
@@ -551,6 +552,44 @@ void TestNotmuchWorker::queryCarriesTheFirstMessageSender()
QStringLiteral("sender-probe@example.org"));
}
+void TestNotmuchWorker::sendersAreCountedForTheCandidateList()
+{
+ // The counts that BusinessSenders::appendCandidates() consumes: per-sender
+ // totals over a query, keyed by the lower-cased BARE address (a display
+ // name would defeat the bulk-sender guess). Two messages from one sender
+ // must count twice.
+ NotmuchFixture fixture;
+ QVERIFY(fixture.isValid());
+ QVERIFY(fixture.addMessage(QStringLiteral("inbox"),
+ QStringLiteral("n1@example.org"),
+ QStringLiteral("Receipt one"),
+ QStringLiteral("noreply@shop.example"),
+ QStringLiteral("Mon, 8 Jun 2026 10:00:00 +0000"),
+ QStringLiteral("body")));
+ QVERIFY(fixture.addMessage(QStringLiteral("inbox"),
+ QStringLiteral("n2@example.org"),
+ QStringLiteral("Receipt two"),
+ QStringLiteral("noreply@shop.example"),
+ QStringLiteral("Tue, 9 Jun 2026 10:00:00 +0000"),
+ QStringLiteral("body")));
+ QVERIFY(fixture.addMessage(QStringLiteral("inbox"),
+ QStringLiteral("j1@example.org"),
+ QStringLiteral("Hello"),
+ QStringLiteral("john@example.org"),
+ QStringLiteral("Wed, 10 Jun 2026 10:00:00 +0000"),
+ QStringLiteral("body")));
+ QVERIFY2(fixture.index(), qPrintable(fixture.error()));
+
+ NotmuchWorker worker(fixture.configPath());
+ QSignalSpy spy(&worker, &NotmuchWorker::senderCountsReady);
+ worker.countSenders(QStringLiteral("*"));
+ QVERIFY(spy.count() > 0);
+
+ const auto counts = spy.first().at(0).value<QHash<QString, int>>();
+ QCOMPARE(counts.value(QStringLiteral("noreply@shop.example")), 2);
+ QCOMPARE(counts.value(QStringLiteral("john@example.org")), 1);
+}
+
void TestNotmuchWorker::loadThreadTreeReportsReplyDepth()
{
// Thread A is a root plus one reply carrying In-Reply-To, which is what