aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-14 18:04:32 +0200
committerDanilo M. <danix@danix.xyz>2026-08-14 18:04:32 +0200
commitde1f7dba196d59cdaa46d2938e5e40e40f97a692 (patch)
tree539fef2d664c1a83cc9ee7c7d69968ddc1f52b37 /tests
parent612eb64871de7e00f21a9b7ebf33d8179caa16bc (diff)
downloadqtmaildir-de1f7dba196d59cdaa46d2938e5e40e40f97a692.tar.gz
qtmaildir-de1f7dba196d59cdaa46d2938e5e40e40f97a692.zip
feat(search): offer Exclude from search in both menus
Third entry in the message pane's submenus and in each details row, greyed rather than hidden when the query bar is empty, so the feature stays visible to someone exploring a fresh window. requestSearch refuses an Exclude with no query as well, so the guard does not rest on the menu's enabled state alone. Mutation checked: disabling that condition fails the new test on the blocked emit. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_messagedetailsdialog.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test_messagedetailsdialog.cpp b/tests/test_messagedetailsdialog.cpp
index 403750b..073611d 100644
--- a/tests/test_messagedetailsdialog.cpp
+++ b/tests/test_messagedetailsdialog.cpp
@@ -36,6 +36,7 @@ private slots:
void offersASearchForEachValue();
void omitsAnEmptyHeader();
void messageIdIsShownButNotSearchable();
+ void excludeIsOfferedOnlyWithAQueryToExcludeFrom();
private:
/// One message, with every header populated. The date's weekday matches
@@ -180,5 +181,43 @@ void TestMessageDetailsDialog::messageIdIsShownButNotSearchable()
QCOMPARE(spy.count(), 0);
}
+void TestMessageDetailsDialog::excludeIsOfferedOnlyWithAQueryToExcludeFrom()
+{
+ // Excluding from an empty query bar would mean the whole Maildir minus one
+ // value: a legitimate query, and an implausible thing to have meant by
+ // right-clicking a value in a fresh window.
+ MessageDetailsDialog withQuery({ oneMessage() }, true);
+ MessageDetailsDialog withoutQuery({ oneMessage() }, false);
+
+ // The menu is built inside a customContextMenuRequested lambda and cannot
+ // be popped without a real context-menu event, so assert on the property
+ // its enabled state is derived from.
+ QVERIFY(withQuery.canExcludeFromSearch());
+ QVERIFY(!withoutQuery.canExcludeFromSearch());
+
+ const QList<HeaderRow> rows = withoutQuery.rows();
+ const auto from = std::find_if(
+ rows.cbegin(), rows.cend(), [](const HeaderRow &row) {
+ return row.field == QStringLiteral("from");
+ });
+ QVERIFY2(from != rows.cend(), "no From row to search from");
+
+ // The emit refuses too, so the guard does not rest on the menu alone.
+ QSignalSpy blocked(&withoutQuery,
+ &MessageDetailsDialog::searchRequested);
+ QVERIFY(blocked.isValid());
+ withoutQuery.requestSearch(*from, SearchTerm::SearchMode::Exclude);
+ QCOMPARE(blocked.count(), 0);
+
+ // And with a query it goes through, so the guard is not simply refusing
+ // every exclude.
+ QSignalSpy allowed(&withQuery, &MessageDetailsDialog::searchRequested);
+ QVERIFY(allowed.isValid());
+ withQuery.requestSearch(*from, SearchTerm::SearchMode::Exclude);
+ QCOMPARE(allowed.count(), 1);
+ QCOMPARE(allowed.at(0).at(1).value<SearchTerm::SearchMode>(),
+ SearchTerm::SearchMode::Exclude);
+}
+
QTEST_MAIN(TestMessageDetailsDialog)
#include "test_messagedetailsdialog.moc"