File indexing completed on 2024-04-28 05:02:15
0001 // SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstraste.com> 0002 // SPDX-License-Identifier: GPL-3.0-or-later 0003 0004 #include "account/accountmanager.h" 0005 #include "account/announcementmodel.h" 0006 #include "helperreply.h" 0007 #include "mockaccount.h" 0008 0009 #include <QtTest/QtTest> 0010 0011 class AnnouncementsTest : public QObject 0012 { 0013 Q_OBJECT 0014 0015 private Q_SLOTS: 0016 void initTestCase() 0017 { 0018 account = new MockAccount(); 0019 AccountManager::instance().addAccount(account, false); 0020 AccountManager::instance().selectAccount(account); 0021 } 0022 0023 void cleanupTestCase() 0024 { 0025 AccountManager::instance().removeAccount(account); 0026 } 0027 0028 void testModel() 0029 { 0030 QUrl url = account->apiUrl(QStringLiteral("/api/v1/announcements")); 0031 account->registerGet(url, new TestReply(QStringLiteral("announcements.json"), account)); 0032 0033 AnnouncementModel announcementsModel; 0034 QCOMPARE(announcementsModel.rowCount({}), 1); 0035 QCOMPARE(announcementsModel.data(announcementsModel.index(0, 0), AnnouncementModel::IdRole).toInt(), 8); 0036 QCOMPARE(announcementsModel.data(announcementsModel.index(0, 0), AnnouncementModel::ContentRole).toString(), 0037 QStringLiteral("<p>Looks like there was an issue processing audio attachments without embedded art since yesterday due to an experimental new " 0038 "feature. That issue has now been fixed, so you may see older posts with audio from other servers pop up in your feeds now as " 0039 "they are being finally properly processed. Sorry!</p>")); 0040 Q_ASSERT(announcementsModel.data(announcementsModel.index(0, 0), AnnouncementModel::PublishedAt).toDate().isValid()); 0041 } 0042 0043 private: 0044 MockAccount *account; 0045 }; 0046 0047 QTEST_MAIN(AnnouncementsTest) 0048 #include "announcementstest.moc"