Skip to content

Commit 6925096

Browse files
committed
test(nextcloud): Test spreed message expiration
Signed-off-by: provokateurin <kate@provokateurin.de>
1 parent 14ae37c commit 6925096

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,36 @@ void main() {
168168
});
169169
});
170170
});
171+
172+
test('Message expiration', () async {
173+
const expiration = 1;
174+
175+
final room = await createTestRoom();
176+
expect(room.lastMessage.baseMessage, isNotNull);
177+
expect(room.lastMessage.builtListNever, isNull);
178+
expect(room.lastMessage.chatMessage, isNotNull);
179+
180+
await tester.client.spreed.room.setMessageExpiration(
181+
token: room.token,
182+
$body: spreed.RoomSetMessageExpirationRequestApplicationJson(
183+
(b) => b.seconds = expiration,
184+
),
185+
);
186+
187+
final clearHistoryResponse = await tester.client.spreed.chat.clearHistory(
188+
token: room.token,
189+
);
190+
expect(clearHistoryResponse.body.ocs.data.expirationTimestamp, isPositive);
191+
192+
await Future<void>.delayed(const Duration(seconds: expiration));
193+
194+
final getRoomResponse = await tester.client.spreed.room.getSingleRoom(
195+
token: room.token,
196+
);
197+
expect(getRoomResponse.body.ocs.data.lastMessage.baseMessage, isNull);
198+
expect(getRoomResponse.body.ocs.data.lastMessage.builtListNever, isNotNull);
199+
expect(getRoomResponse.body.ocs.data.lastMessage.chatMessage, isNull);
200+
});
171201
});
172202

173203
group('Avatar', () {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
POST http://localhost/ocs/v2\.php/apps/spreed/api/v4/room/[a-z0-9]{8}/message-expiration
8+
accept: application/json
9+
authorization: Bearer mock
10+
content-type: application/json; charset=utf-8
11+
ocs-apirequest: true
12+
\{"seconds":1\}
13+
DELETE http://localhost/ocs/v2\.php/apps/spreed/api/v1/chat/[a-z0-9]{8}
14+
accept: application/json
15+
authorization: Bearer mock
16+
ocs-apirequest: true
17+
GET http://localhost/ocs/v2\.php/apps/spreed/api/v4/room/[a-z0-9]{8}
18+
accept: application/json
19+
authorization: Bearer mock
20+
ocs-apirequest: true

0 commit comments

Comments
 (0)