From 86074f40121466798cdd64e07a00db2542543c52 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 14 Aug 2026 18:25:03 +0200 Subject: fix(startup): raise the config-problem modal outside the constructor showWarnings() did two separable things and one of them could not be reached from a test. It set the status label, which is harmless, and it raised a QMessageBox from the MainWindow constructor, which under the offscreen platform nothing can dismiss: the constructor never returned and the suite hung with no output, reading as an infrastructure failure rather than a test one. It splits in two. applyWarnings() keeps the status label and stays in the constructor. configProblems() returns the list, and main.cpp raises the dialog after show(), which also gives it a visible parent to sit on. The distinction between warnings and problems is preserved exactly: a keybinding being ignored interrupts startup, "no sync command configured" does not. The warning path now has its first test, using the config shape that caused the original hang. Mutation checked by putting the modal back in the constructor: the test times out at 124 rather than failing, which is the behaviour this removes. Co-Authored-By: Claude Opus 5 --- tests/test_mainwindow.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'tests') diff --git a/tests/test_mainwindow.cpp b/tests/test_mainwindow.cpp index 0bf8925..be3a28f 100644 --- a/tests/test_mainwindow.cpp +++ b/tests/test_mainwindow.cpp @@ -91,6 +91,7 @@ private slots: void aSearchFromThePaneReplacesTheQuery(); void aSearchFromThePaneCanNarrowTheQuery(); void narrowingAnEmptyQueryBarIsAPlainSearch(); + void aMalformedAccountIsReportedWithoutBlockingTheConstructor(); void autoSyncIsNotArmedWhenDisabledOrWithNothingPending(); void autoSyncSkipsWhileABackgroundSyncIsRunning(); void aSuccessfulSyncRefreshesRatherThanRerunningTheQuery(); @@ -6105,4 +6106,38 @@ void TestMainWindow::renamingReplacesRatherThanDuplicating() QCOMPARE(savedQueryButtonLabels(window), QStringList{ QStringLiteral("New") }); } +void TestMainWindow::aMalformedAccountIsReportedWithoutBlockingTheConstructor() +{ + // The exact shape that hung the suite on 2026-08-14: an account section + // carrying `sent=` and no `maildir=`. Config::load handles it correctly, + // recording a problem and carrying on, but showWarnings() then raised a + // modal FROM THE CONSTRUCTOR, which nothing can dismiss under the + // offscreen platform, so MainWindow never finished constructing. + // + // Constructing the window at all is therefore half the assertion: if the + // modal comes back, this test does not fail, it HANGS. + QTemporaryDir dir; + QVERIFY(dir.isValid()); + + const QString path = dir.filePath(QStringLiteral("qtmaildir.conf")); + { + QFile file(path); + QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text)); + QTextStream out(&file); + out << "[account.one]\n" + << "sent=Sent\n"; + } + + Config config; + config.load(path); + + MainWindow window(config); + + // The problem is reported rather than swallowed, and it names the account. + const QStringList problems = window.configProblems(); + QVERIFY2(!problems.isEmpty(), + "a malformed account produced no problem to report"); + QVERIFY(problems.join(QLatin1Char('\n')).contains(QStringLiteral("one"))); +} + #include "test_mainwindow.moc" -- cgit v1.2.3