Skip to content

Commit 14ae37c

Browse files
committed
test(nextcloud): Test spreed clear chat history
Signed-off-by: provokateurin <kate@provokateurin.de>
1 parent 115e05d commit 14ae37c

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

packages/nextcloud/test/api/spreed/spreed_test.dart

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,34 @@ void main() {
463463
expect(response.body.ocs.data.parent!.chatMessage!.messageType, spreed.MessageType.commentDeleted);
464464
expect(response.body.ocs.data.parent!.chatMessage!.systemMessage, '');
465465
});
466+
467+
test('Clear history', () async {
468+
final room = await createTestRoom();
469+
470+
final clearHistoryResponse = await tester.client.spreed.chat.clearHistory(
471+
token: room.token,
472+
);
473+
expect(clearHistoryResponse.body.ocs.data.id, isPositive);
474+
expect(clearHistoryResponse.body.ocs.data.actorType, spreed.ActorType.users);
475+
expect(clearHistoryResponse.body.ocs.data.actorId, 'user1');
476+
expect(clearHistoryResponse.body.ocs.data.actorDisplayName, 'User One');
477+
expect(clearHistoryResponse.body.ocs.data.message, 'You cleared the history of the conversation');
478+
expect(clearHistoryResponse.body.ocs.data.messageType, spreed.MessageType.system);
479+
expect(clearHistoryResponse.body.ocs.data.systemMessage, 'history_cleared');
480+
481+
final receiveMessagesResponse = await tester.client.spreed.chat.receiveMessages(
482+
token: room.token,
483+
lookIntoFuture: spreed.ChatReceiveMessagesLookIntoFuture.$0,
484+
);
485+
expect(receiveMessagesResponse.body.ocs.data, hasLength(1));
486+
expect(receiveMessagesResponse.body.ocs.data[0].id, isPositive);
487+
expect(receiveMessagesResponse.body.ocs.data[0].actorType, spreed.ActorType.users);
488+
expect(receiveMessagesResponse.body.ocs.data[0].actorId, 'user1');
489+
expect(receiveMessagesResponse.body.ocs.data[0].actorDisplayName, 'User One');
490+
expect(receiveMessagesResponse.body.ocs.data[0].message, 'You cleared the history of the conversation');
491+
expect(receiveMessagesResponse.body.ocs.data[0].messageType, spreed.MessageType.system);
492+
expect(receiveMessagesResponse.body.ocs.data[0].systemMessage, 'history_cleared');
493+
});
466494
});
467495

468496
group('Call', () {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
POST http://localhost/ocs/v2\.php/apps/spreed/api/v4/room
2+
accept: application/json
3+
authorization: Bearer mock
4+
content-type: application/json; charset=utf-8
5+
ocs-apirequest: true
6+
\{"roomType":3,"invite":"","roomName":"Test","source":"","objectType":"","objectId":""\}
7+
DELETE http://localhost/ocs/v2\.php/apps/spreed/api/v1/chat/[a-z0-9]{8}
8+
accept: application/json
9+
authorization: Bearer mock
10+
ocs-apirequest: true
11+
GET http://localhost/ocs/v2\.php/apps/spreed/api/v1/chat/[a-z0-9]{8}\?lookIntoFuture=0&limit=100&lastKnownMessageId=0&lastCommonReadId=0&timeout=30&setReadMarker=1&includeLastKnown=0&noStatusUpdate=0&markNotificationsAsRead=1
12+
accept: application/json
13+
authorization: Bearer mock
14+
ocs-apirequest: true

0 commit comments

Comments
 (0)