aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-14 19:24:38 +0200
committerDanilo M. <danix@danix.xyz>2026-08-14 19:24:38 +0200
commitf6658a12c85edec13890cfc1409d2f604730292d (patch)
treebedfb35f370b637eedcb3cd4d24be8ac75b257b5
parent4a4f82f7709ab6ee5a84ac0f3b191470b6424c36 (diff)
downloadqtmaildir-f6658a12c85edec13890cfc1409d2f604730292d.tar.gz
qtmaildir-f6658a12c85edec13890cfc1409d2f604730292d.zip
test(worker): cover the Sent view's matched-message branch
Asserted by hand until now, which meant asking the user to look at the one branch I had rewritten twice after misreading the libnotmuch API. Both directions in one test: a query matching only the reply reports the reply under withRecipients, and the same thread under an ordinary query still reports its opening message, so this is a Sent special case rather than a change of meaning everywhere. Mutation checked: disabling the branch makes a Sent row report a1@example.org, the thread's opener, where a2@example.org is the message that matched. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
-rw-r--r--tests/test_notmuchworker.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/test_notmuchworker.cpp b/tests/test_notmuchworker.cpp
index f8dfe91..de96dbf 100644
--- a/tests/test_notmuchworker.cpp
+++ b/tests/test_notmuchworker.cpp
@@ -63,6 +63,7 @@ private slots:
void loadMessageReturnsOnlyThatMessage();
void loadMessageOnAnUnknownIdReturnsNothing();
void aQueryCarriesEachThreadsFirstMessageId();
+ void aSentQueryCarriesTheMatchedMessageNotTheThreadsFirst();
void loadThreadTreeReportsReplyDepth();
void loadThreadTreeCarriesTheFactsARowNeeds();
@@ -273,6 +274,42 @@ void TestNotmuchWorker::aQueryCarriesEachThreadsFirstMessageId()
QVERIFY2(sawTheThread, "the two-message thread was not in the results");
}
+void TestNotmuchWorker::aSentQueryCarriesTheMatchedMessageNotTheThreadsFirst()
+{
+ // THE case the Sent branch exists for, and the one hardest to get right.
+ // In a Sent view a row stands for what the USER sent, which is normally a
+ // reply. Taking the thread's opening message there would show whoever
+ // started the conversation instead, under a heading that says Sent.
+ //
+ // "Release notes" is a1 (the root) plus a2 (its reply). A query matching
+ // only the reply stands in for a Sent query: withRecipients is what the
+ // Sent view sets, and it is what selects the matched-message branch.
+ const QVector<ThreadSummary> asSent =
+ runQuery(QStringLiteral("id:a2@example.org"),
+ NotmuchWorker::NewestFirst, /*withRecipients=*/true);
+
+ bool sawIt = false;
+ for (const ThreadSummary &t : asSent) {
+ if (t.subject != QStringLiteral("Release notes"))
+ continue;
+ // The REPLY, because that is what matched. Not a1, the thread's first.
+ QCOMPARE(t.firstMessageId, QStringLiteral("a2@example.org"));
+ sawIt = true;
+ }
+ QVERIFY2(sawIt, "the thread was not in the results at all");
+
+ // And the same thread under an ordinary query still reports its opening
+ // message, so the branch is a Sent special case and not a change of
+ // meaning for everything else.
+ const QVector<ThreadSummary> asInbox =
+ runQuery(QStringLiteral("id:a2@example.org"),
+ NotmuchWorker::NewestFirst, /*withRecipients=*/false);
+ for (const ThreadSummary &t : asInbox) {
+ if (t.subject == QStringLiteral("Release notes"))
+ QCOMPARE(t.firstMessageId, QStringLiteral("a1@example.org"));
+ }
+}
+
void TestNotmuchWorker::loadThreadTreeReportsReplyDepth()
{
// Thread A is a root plus one reply carrying In-Reply-To, which is what