aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_config.cpp
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-03 16:31:34 +0200
committerDanilo M. <danix@danix.xyz>2026-08-03 16:31:34 +0200
commit2c33529fb665cb54c31e54230fcb7b2491cf8565 (patch)
tree87410a035212f0e8e5997722662803c17a3320d8 /tests/test_config.cpp
parent212048782be680e2f99341db6c6460e59c708e7c (diff)
downloadqtmaildir-feature/ui-state-persistence.tar.gz
qtmaildir-feature/ui-state-persistence.zip
feat: choose the startup query by namefeature/ui-state-persistence
The app opened whichever saved query sorted first alphabetically, which is not a choice anyone made: [queries] is read through childKeys(), so savedQueries().first() means "Flagged" before "Inbox" before "Unread" rather than anything the user expressed. [general] startup_query names the entry to open and defaults to Unread, so a fresh install comes up on the unified unread list. Saved-query button order is untouched and stays alphabetical. A name matching no saved query falls back to the first one rather than starting with an empty view. That is reported as a problem only when the user actually wrote the name; the built-in default naming a query they never created is not something they got wrong, and warning about it would fire on every launch of a config that has no Unread entry. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'tests/test_config.cpp')
-rw-r--r--tests/test_config.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/test_config.cpp b/tests/test_config.cpp
index 367643c..24f6afb 100644
--- a/tests/test_config.cpp
+++ b/tests/test_config.cpp
@@ -34,6 +34,9 @@ private slots:
void brokenSyncCommandIsAProblem();
void malformedAccountIsAProblem();
void validConfigHasNoProblems();
+ void startupQueryDefaultsToUnread();
+ void startupQueryHonoursTheConfiguredName();
+ void unknownStartupQueryFallsBackAndReports();
void generalSectionKeysAreActuallyRead();
void messageZoomDefaultsAndValidates();
};
@@ -224,6 +227,70 @@ void TestConfig::validConfigHasNoProblems()
QVERIFY(config.warnings().isEmpty());
}
+void TestConfig::startupQueryDefaultsToUnread()
+{
+ // [queries] is read through childKeys(), which sorts alphabetically, so
+ // savedQueries().first() is "Flagged" here. The startup query must be
+ // chosen by name, not by sort order.
+ QTemporaryDir dir;
+ Config config;
+ config.load(writeIni(dir, QStringLiteral(
+ "[queries]\n"
+ "Inbox=tag:inbox\n"
+ "Unread=tag:unread\n"
+ "Flagged=tag:flagged\n")));
+
+ QCOMPARE(config.savedQueries().first().name, QStringLiteral("Flagged"));
+ QCOMPARE(config.startupSavedQuery().name, QStringLiteral("Unread"));
+ QCOMPARE(config.startupSavedQuery().query, QStringLiteral("tag:unread"));
+ QVERIFY(config.problems().isEmpty());
+}
+
+void TestConfig::startupQueryHonoursTheConfiguredName()
+{
+ QTemporaryDir dir;
+ Config config;
+ config.load(writeIni(dir, QStringLiteral(
+ "[general]\n"
+ "startup_query=Flagged\n"
+ "\n"
+ "[queries]\n"
+ "Inbox=tag:inbox\n"
+ "Unread=tag:unread\n"
+ "Flagged=tag:flagged\n")));
+
+ QCOMPARE(config.startupSavedQuery().name, QStringLiteral("Flagged"));
+ QVERIFY(config.problems().isEmpty());
+}
+
+void TestConfig::unknownStartupQueryFallsBackAndReports()
+{
+ // A name the user wrote that matches nothing is a problem: they asked for
+ // something and are not getting it. Startup still works, on the fallback.
+ QTemporaryDir dir;
+ Config config;
+ config.load(writeIni(dir, QStringLiteral(
+ "[general]\n"
+ "startup_query=Nonexistent\n"
+ "\n"
+ "[queries]\n"
+ "Inbox=tag:inbox\n")));
+
+ QCOMPARE(config.startupSavedQuery().name, QStringLiteral("Inbox"));
+ QCOMPARE(config.problems().size(), 1);
+
+ // The built-in default naming a query the user never created is NOT a
+ // problem: they did not get it wrong, they simply have no Unread entry.
+ QTemporaryDir quiet;
+ Config silent;
+ silent.load(writeIni(quiet, QStringLiteral(
+ "[queries]\n"
+ "Inbox=tag:inbox\n")));
+
+ QCOMPARE(silent.startupSavedQuery().name, QStringLiteral("Inbox"));
+ QVERIFY(silent.problems().isEmpty());
+}
+
void TestConfig::generalSectionKeysAreActuallyRead()
{
// QSettings' INI backend treats a section literally named [general] as its