Unit tests for federated share activity actions
authoralex-z <blackslayer4@gmail.com>
Mon, 4 Mar 2024 13:00:20 +0000 (14:00 +0100)
committerMatthieu Gallien <matthieu_gallien@yahoo.fr>
Tue, 5 Mar 2024 08:13:12 +0000 (09:13 +0100)
Signed-off-by: alex-z <blackslayer4@gmail.com>
test/activitylistmodeltestutils.cpp
test/testactivitylistmodel.cpp

index 69c793895f7309626e62bba79d405a964050b3e7..2cdf5a003cba7f307588471f1ce982c89e2b12f5 100644 (file)
@@ -403,6 +403,41 @@ void FakeRemoteActivityStorage::initActivityData()
 
         _startingId++;
     }
+
+    for (quint32 i = 0; i < _numItemsToInsert; i++) {
+        QJsonObject activity;
+        activity.insert(QStringLiteral("activity_id"), _startingId);
+        activity.insert(QStringLiteral("object_type"), "remote_share");
+        activity.insert(QStringLiteral("subject"), QStringLiteral("You received document.docx as a remote share from admin@https://example.de"));
+        activity.insert(QStringLiteral("subjectRich"), QStringLiteral("You received {share} as a remote share from {user}"));
+        activity.insert(QStringLiteral("message"), QStringLiteral(""));
+        activity.insert(QStringLiteral("object_name"), QStringLiteral(""));
+        activity.insert(QStringLiteral("datetime"), QDateTime::currentDateTime().toString(Qt::ISODate));
+        activity.insert(QStringLiteral("icon"), QStringLiteral("http://example.de/core/img/actions/share.svg"));
+
+        QJsonArray actionsArray;
+
+        QJsonObject primaryAction;
+        primaryAction.insert(QStringLiteral("label"), QStringLiteral("Accept"));
+        primaryAction.insert(QStringLiteral("link"), QStringLiteral("/ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/6"));
+        primaryAction.insert(QStringLiteral("type"), QStringLiteral("POST"));
+        primaryAction.insert(QStringLiteral("primary"), true);
+        actionsArray.push_back(primaryAction);
+
+        QJsonObject secondaryAction;
+        secondaryAction.insert(QStringLiteral("label"), QStringLiteral("Decline"));
+        secondaryAction.insert(QStringLiteral("link"), QString(QStringLiteral("/ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/6")));
+        secondaryAction.insert(QStringLiteral("type"), QStringLiteral("DELETE"));
+        secondaryAction.insert(QStringLiteral("primary"), false);
+        actionsArray.push_back(secondaryAction);
+
+        activity.insert(QStringLiteral("actions"), actionsArray);
+
+        _activityData.push_back(activity);
+
+        _startingId++;
+    }
+
     _startingId--;
 }
 
index f5a69b3ea8c5944feeafe26c6f7107b10603a2cc..d238e3dfd1f13db0d169cc8a218467e2f673e7fe 100644 (file)
@@ -297,6 +297,14 @@ private slots:
                         QVERIFY(actionsLinksContextMenu.isEmpty());
                     }
 
+                    // remote shares must have 'Accept' and 'Decline' actions
+                    if (objectType == QStringLiteral("remote_share")) {
+                        QVERIFY(actionsLinks.size() == 2);
+                        QVERIFY(actionsLinks[0].value<OCC::ActivityLink>()._primary);
+                        QVERIFY(actionsLinks[0].value<OCC::ActivityLink>()._verb == QStringLiteral("POST"));
+                        QVERIFY(actionsLinks[1].value<OCC::ActivityLink>()._verb == QStringLiteral("DELETE"));
+                    }
+
                     if ((objectType == QStringLiteral("chat") || objectType == QStringLiteral("call")
                             || objectType == QStringLiteral("room"))) {