From 496e174e65c06563aff426bdbbeeba006102e89d Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 26 Aug 2026 16:22:49 +0200 Subject: feat: propose business senders from newly synced mail --- tests/test_notmuchworker.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'tests/test_notmuchworker.cpp') 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>(); + 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 -- cgit v1.2.3