diff options
| author | Danilo M. <danix@danix.xyz> | 2026-08-13 11:46:16 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-08-13 11:46:16 +0200 |
| commit | 4a9bbff4cb157538106b588bc84f39dd7fd38289 (patch) | |
| tree | 8de3507237e53d369338c7c1d4ee9bf1f8f57dd9 /tests | |
| parent | 8913a1190c48ff2672f8783af8594ca11e49ccf7 (diff) | |
| download | qtmaildir-4a9bbff4cb157538106b588bc84f39dd7fd38289.tar.gz qtmaildir-4a9bbff4cb157538106b588bc84f39dd7fd38289.zip | |
feat(rules): a folder dropdown, so the path suffix is never typed
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_tagrules.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/test_tagrules.cpp b/tests/test_tagrules.cpp index 2302111..8207b3c 100644 --- a/tests/test_tagrules.cpp +++ b/tests/test_tagrules.cpp @@ -47,6 +47,7 @@ private slots: void editingARowRewritesTheQuery(); void aTextModeRuleStaysTextWhenAnotherRuleIsVisited(); void leavingTextModeIsRefusedWhenTheQueryCannotBeShownAsRows(); + void aFolderRowUsesTheDropdownAndKeepsItsSuffix(); private: QString writeRules(const QString &json); @@ -544,5 +545,50 @@ void TestTagRules::leavingTextModeIsRefusedWhenTheQueryCannotBeShownAsRows() "a stale refusal must not outlive the query that caused it"); } +void TestTagRules::aFolderRowUsesTheDropdownAndKeepsItsSuffix() +{ + // A path: without its suffix matches nothing and notmuch says nothing + // about it, so the suffix must never depend on the user typing it. + QTemporaryDir configHome; + QVERIFY(configHome.isValid()); + qputenv("XDG_CONFIG_HOME", configHome.path().toUtf8()); + QVERIFY(QDir().mkpath(configHome.filePath(QStringLiteral("mailrules")))); + + const QString stored = configHome.filePath( + QStringLiteral("mailrules/rules.json")); + QFile out(stored); + QVERIFY(out.open(QIODevice::WriteOnly)); + out.write(R"({ + "version": 1, + "rules": [ + {"id": "account", "query": "path:\"account-one/**\"", + "add": ["account-one"], "stage": 10, "enabled": true} + ] + })"); + out.close(); + + TagRulesDialog dialog; + dialog.setFolders({QStringLiteral("account-one"), + QStringLiteral("account-two")}); + + // The stored rule round-trips: the row holds the bare name, and the + // query keeps the suffix. + QCOMPARE(dialog.rowCountForTest(), 1); + QCOMPARE(dialog.queryLineForTest(), + QStringLiteral("path:\"account-one/**\"")); + + dialog.setRowValueForTest(0, QStringLiteral("account-two")); + QCOMPARE(dialog.queryLineForTest(), + QStringLiteral("path:\"account-two/**\"")); + + dialog.saveForTest(); + + TagRules reloaded; + reloaded.load(stored); + QCOMPARE(reloaded.rules().size(), 1); + QCOMPARE(reloaded.rules().at(0).query, + QStringLiteral("path:\"account-two/**\"")); +} + QTEST_MAIN(TestTagRules) #include "test_tagrules.moc" |
