From 3ee73d48c9d819b2e186655b7ba86ebc2a961baf Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Mon, 3 Aug 2026 09:28:33 +0200 Subject: fix: only interrupt startup for real configuration problems Found while walking the task 13 checklist against real mail. Item 1 ("startup shows no configuration warnings with a valid config") failed: with a perfectly valid config that simply had no [sync] command, every launch opened a blocking modal that had to be dismissed before the window could be used. Config now separates the two cases. A problem is something configured but wrong (a sync command that does not exist, an account with no maildir); those still open a dialog, as does every KeyMap warning, since each one means a binding the user wrote is being ignored. A notice is an optional feature simply not being configured; it reports to the status bar only. Nothing is broken in that case, and a modal on every launch teaches the user to dismiss dialogs unread, which defeats the ones that matter. problems() is a subset of warnings(), so callers wanting everything need only the latter. Co-Authored-By: Claude Opus 5 --- tests/test_config.cpp | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) (limited to 'tests') diff --git a/tests/test_config.cpp b/tests/test_config.cpp index 0caa93c..50d7e67 100644 --- a/tests/test_config.cpp +++ b/tests/test_config.cpp @@ -12,6 +12,10 @@ private slots: void missingSyncCommandIsEmpty(); void accountWithoutMaildirIsRejected(); void scopedQueryWrapsCorrectly(); + void absentSyncCommandIsNoticeNotProblem(); + void brokenSyncCommandIsAProblem(); + void malformedAccountIsAProblem(); + void validConfigHasNoProblems(); }; static QString writeIni(const QTemporaryDir &dir, const QString &body) @@ -128,5 +132,77 @@ void TestConfig::scopedQueryWrapsCorrectly() QStringLiteral("path:\"work-mail/**\"")); } +void TestConfig::absentSyncCommandIsNoticeNotProblem() +{ + // An optional feature simply not being configured must not interrupt + // startup: the modal would fire on every launch and train the user to + // dismiss dialogs without reading them. + QTemporaryDir dir; + const QString path = writeIni(dir, QStringLiteral( + "[account.work]\n" + "maildir=work-mail\n")); + + Config config; + config.load(path); + + QCOMPARE(config.warnings().size(), 1); + QVERIFY(config.warnings().first().contains(QStringLiteral("No sync command"))); + QVERIFY(config.problems().isEmpty()); +} + +void TestConfig::brokenSyncCommandIsAProblem() +{ + // Configured but missing is different: the user asked for sync and is not + // getting it, so they need telling. + QTemporaryDir dir; + const QString path = writeIni(dir, QStringLiteral( + "[sync]\n" + "command=/nonexistent/qtmaildir-test/mailsync.sh\n" + "\n" + "[account.work]\n" + "maildir=work-mail\n")); + + Config config; + config.load(path); + + QCOMPARE(config.problems().size(), 1); + QVERIFY(config.problems().first().contains(QStringLiteral("does not exist"))); + // Problems are a subset of warnings, so a caller wanting everything needs + // only warnings(). + QVERIFY(config.warnings().contains(config.problems().first())); +} + +void TestConfig::malformedAccountIsAProblem() +{ + QTemporaryDir dir; + const QString path = writeIni(dir, QStringLiteral( + "[account.broken]\n" + "name=No Maildir Here\n")); + + Config config; + config.load(path); + + QVERIFY(!config.problems().isEmpty()); + QVERIFY(config.problems().first().contains(QStringLiteral("broken"))); +} + +void TestConfig::validConfigHasNoProblems() +{ + QTemporaryDir dir; + const QString path = writeIni(dir, QStringLiteral( + "[sync]\n" + "command=/bin/true\n" + "\n" + "[account.work]\n" + "maildir=work-mail\n" + "address=user@example.org\n")); + + Config config; + config.load(path); + + QVERIFY(config.problems().isEmpty()); + QVERIFY(config.warnings().isEmpty()); +} + QTEST_MAIN(TestConfig) #include "test_config.moc" -- cgit v1.2.3