summaryrefslogtreecommitdiffstats
path: root/tests/test_mainwindow.cpp
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-14 17:14:33 +0200
committerDanilo M. <danix@danix.xyz>2026-08-14 17:14:33 +0200
commita79725e055699524ec57d09bd484f274ea4a961e (patch)
tree8ca944300b3f8e2650940154df73aa8b561bb3b8 /tests/test_mainwindow.cpp
parente876e509b0770a243725b63ea55c9ccf3e41b1bf (diff)
parentbbf3c570215688c553fd70d8f372ae215725ca02 (diff)
downloadqtmaildir-a79725e055699524ec57d09bd484f274ea4a961e.tar.gz
qtmaildir-a79725e055699524ec57d09bd484f274ea4a961e.zip
Merge: searching from the message pane (item 85)
Five surfaces in the message pane offer a search built from what they show: the header's subject and date, its sender and recipients on a single-message thread, a tag chip, a body selection, and every header per message in the details dialog. Each offers Search for this, which replaces the query, and Add to search, which narrows it. The details dialog became labelled rows along the way, which the user wanted independently of this feature. Hand tested through every surface, including the case the parenthesising exists for: adding a sender to 'tag:inbox or tag:flagged' narrows it rather than widening it.
Diffstat (limited to 'tests/test_mainwindow.cpp')
-rw-r--r--tests/test_mainwindow.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/test_mainwindow.cpp b/tests/test_mainwindow.cpp
index 6e300bf..8b60e37 100644
--- a/tests/test_mainwindow.cpp
+++ b/tests/test_mainwindow.cpp
@@ -88,6 +88,9 @@ private slots:
void markReadTimerIsNotArmedForAReadThread();
void aConfirmedEditArmsTheAutoSync();
void autoSyncDebouncesABurstOfEdits();
+ void aSearchFromThePaneReplacesTheQuery();
+ void aSearchFromThePaneCanNarrowTheQuery();
+ void narrowingAnEmptyQueryBarIsAPlainSearch();
void autoSyncIsNotArmedWhenDisabledOrWithNothingPending();
void autoSyncSkipsWhileABackgroundSyncIsRunning();
void aSuccessfulSyncRefreshesRatherThanRerunningTheQuery();
@@ -3725,6 +3728,66 @@ void TestMainWindow::autoSyncDebouncesABurstOfEdits()
1);
}
+void TestMainWindow::aSearchFromThePaneReplacesTheQuery()
+{
+ const Config config;
+ MainWindow window(config);
+
+ QLineEdit *queryEdit =
+ window.findChild<QLineEdit *>(QStringLiteral("queryEdit"));
+ QVERIFY2(queryEdit, "no query bar: the window was never built");
+
+ MessageView *view = window.findChild<MessageView *>();
+ QVERIFY2(view, "no message view");
+
+ queryEdit->setText(QStringLiteral("tag:inbox"));
+ emit view->searchRequested(QStringLiteral("from:\"foo@example.org\""), false);
+
+ QCOMPARE(queryEdit->text(), QStringLiteral("from:\"foo@example.org\""));
+}
+
+void TestMainWindow::aSearchFromThePaneCanNarrowTheQuery()
+{
+ // The case the feature exists for: a query returning a thousand threads is
+ // narrowed by adding a condition. BOTH sides are parenthesised, because
+ // 'a or b AND c' binds as 'a or (b AND c)', which WIDENS a search the user
+ // asked to narrow, and notmuch reports no error for it.
+ const Config config;
+ MainWindow window(config);
+
+ QLineEdit *queryEdit =
+ window.findChild<QLineEdit *>(QStringLiteral("queryEdit"));
+ QVERIFY2(queryEdit, "no query bar: the window was never built");
+
+ MessageView *view = window.findChild<MessageView *>();
+ QVERIFY2(view, "no message view");
+
+ queryEdit->setText(QStringLiteral("tag:inbox or tag:flagged"));
+ emit view->searchRequested(QStringLiteral("from:\"foo@example.org\""), true);
+
+ QCOMPARE(queryEdit->text(),
+ QStringLiteral("(tag:inbox or tag:flagged) AND (from:\"foo@example.org\")"));
+}
+
+void TestMainWindow::narrowingAnEmptyQueryBarIsAPlainSearch()
+{
+ // Rather than "() AND (x)", which matches nothing.
+ const Config config;
+ MainWindow window(config);
+
+ QLineEdit *queryEdit =
+ window.findChild<QLineEdit *>(QStringLiteral("queryEdit"));
+ QVERIFY2(queryEdit, "no query bar: the window was never built");
+
+ MessageView *view = window.findChild<MessageView *>();
+ QVERIFY2(view, "no message view");
+
+ queryEdit->clear();
+ emit view->searchRequested(QStringLiteral("tag:inbox"), true);
+
+ QCOMPARE(queryEdit->text(), QStringLiteral("tag:inbox"));
+}
+
void TestMainWindow::autoSyncIsNotArmedWhenDisabledOrWithNothingPending()
{
// A negative delay is the switch that restores the pre-0.16.0 behaviour, so