diff options
| author | Danilo M. <danix@danix.xyz> | 2026-08-07 17:51:52 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-08-07 17:51:52 +0200 |
| commit | 334b510e2673a6ab3875ffa7a4c5b3b2dd09a369 (patch) | |
| tree | 59b38af32af41d629a0c02ecd8e0fcfcddbb60e6 /tests/test_notmuchworker.cpp | |
| parent | 6003bab2d4c491a857b7a728f2f23c719723ef1a (diff) | |
| download | qtmaildir-334b510e2673a6ab3875ffa7a4c5b3b2dd09a369.tar.gz qtmaildir-334b510e2673a6ab3875ffa7a4c5b3b2dd09a369.zip | |
feat(ui): fill the blank message pane with a branded placeholder
An empty right pane said nothing, and multi-select made it a routine
sight. It now carries the wordmark, thread counts that run their query
when clicked, and a sync line that appears only when something needs
attention.
Rendered into the existing web view as a third document shape, so there
is one document path and one set of security rules. The brand palette is
a deliberate exception to deriving colours from the desktop theme, since
a logo is brand rather than chrome; the theme still picks which of the
two sets is used.
Counts refresh when the pane is about to show rather than in the
background: one goes stale the moment a tag is edited, and refreshing one
nobody is looking at is work for nothing. A generation counter discards a
superseded reply, and a late answer cannot repaint over an opened thread.
The helper lines are real links because JavaScript is off in this
profile. The handler is gated on the placeholder actually being
displayed, so the same URL inside a message body is dropped: a stranger's
mail must not drive the thread list, even to run a harmless query.
Three defects found while building, all silent:
- Every CSS percentage was invalid. QString::arg does not collapse "%%"
into "%", so the document carried "50%%" and the browser dropped each
declaration holding one, disabling the mask, the glow and both radial
gradients while still rendering something plausible. Substitution is by
named token now, which cannot collide with a percent sign.
- A geometry probe endorsed the layout while that was live, because it
measured only properties without percentages.
- The font test passed against a build with one face missing, since the
other satisfied both of its checks on its own.
The mockup's light values needed correcting against a real pane: the grid
vanished at a 2% luminance step on white, and the glow subtracts light
there rather than adding it, washing the pane. Strength only, not hue.
Diffstat (limited to 'tests/test_notmuchworker.cpp')
| -rw-r--r-- | tests/test_notmuchworker.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/test_notmuchworker.cpp b/tests/test_notmuchworker.cpp index 488b630..be62ad3 100644 --- a/tests/test_notmuchworker.cpp +++ b/tests/test_notmuchworker.cpp @@ -58,6 +58,9 @@ private slots: void requestAllTagsReturnsSortedTags(); void requestAllTagsOnUnreadableConfigEmitsError(); + void requestCountsAnswersOneCountPerQuery(); + void requestCountsKeepsPositionOnAnInvalidQuery(); + private: /// Tags of one message, read back through a fresh worker query. QStringList tagsOf(const QString &messageId); @@ -472,5 +475,53 @@ void TestNotmuchWorker::requestAllTagsOnUnreadableConfigEmitsError() QVERIFY(ready.isEmpty()); } +void TestNotmuchWorker::requestCountsAnswersOneCountPerQuery() +{ + NotmuchWorker worker(m_fixture.configPath()); + QSignalSpy spy(&worker, &NotmuchWorker::countsReady); + + worker.requestCounts({ QStringLiteral("tag:unread"), + QStringLiteral("tag:inbox"), + QStringLiteral("tag:flagged") }, 9); + + QCOMPARE(spy.count(), 1); + QCOMPARE(spy.at(0).at(1).value<quint64>(), quint64(9)); + + // Threads, not messages: thread A holds two messages and must count once, + // which is the number the pane's "N in inbox" line claims to be showing. + const QVector<int> counts = spy.at(0).at(0).value<QVector<int>>(); + QCOMPARE(counts, QVector<int>({ 1, 3, 0 })); +} + +void TestNotmuchWorker::requestCountsKeepsPositionOnAnInvalidQuery() +{ + // The caller pairs answers with its own labels by index, so every query + // must produce exactly one entry at its own position. Dropping one would + // shift every later count onto the wrong label, and the pane would show a + // real number against the wrong name rather than visibly breaking. + // + // **notmuch's query parser rejects almost nothing.** malformedQuery... + // above records the same finding: an unbalanced quote parses and matches + // nothing. `((((` behaves the same way and counts 0 rather than failing, + // which is why this asserts the positional contract rather than a -1 that + // no query string can actually provoke. The -1 branch remains for a + // notmuch_query_create allocation failure, which a test cannot reach. + NotmuchWorker worker(m_fixture.configPath()); + QSignalSpy spy(&worker, &NotmuchWorker::countsReady); + + worker.requestCounts({ QStringLiteral("tag:unread"), + QStringLiteral("(((("), + QStringLiteral("tag:inbox") }, 1); + + QCOMPARE(spy.count(), 1); + const QVector<int> counts = spy.at(0).at(0).value<QVector<int>>(); + QCOMPARE(counts.size(), 3); + + // The queries either side keep their own answers, which is the property + // the pane depends on. + QCOMPARE(counts.at(0), 1); + QCOMPARE(counts.at(2), 3); +} + QTEST_MAIN(TestNotmuchWorker) #include "test_notmuchworker.moc" |
