Browse Source

Add integration tests for unread messages

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
pull/6625/head
Daniel Calviño Sánchez 4 years ago
committed by Joas Schilling
parent
commit
44e3b6c22f
No known key found for this signature in database GPG Key ID: 7076EA9751AACDDA
  1. 3
      tests/integration/features/bootstrap/FeatureContext.php
  2. 135
      tests/integration/features/chat/unread-messages.feature

3
tests/integration/features/bootstrap/FeatureContext.php

@ -314,6 +314,9 @@ class FeatureContext implements Context, SnippetAcceptingContext {
if (isset($expectedRoom['lastMessage'])) {
$data['lastMessage'] = $room['lastMessage'] ? $room['lastMessage']['message'] : '';
}
if (isset($expectedRoom['unreadMessages'])) {
$data['unreadMessages'] = (int) $room['unreadMessages'];
}
if (isset($expectedRoom['unreadMention'])) {
$data['unreadMention'] = (int) $room['unreadMention'];
}

135
tests/integration/features/chat/unread-messages.feature

@ -0,0 +1,135 @@
Feature: chat/unread-messages
Background:
Given user "participant1" exists
Given user "participant2" exists
Scenario: sending a message clears unread counter for sender
Given user "participant1" creates room "group room" (v4)
| roomType | 2 |
| roomName | room |
And user "participant1" adds user "participant2" to room "group room" with 200 (v4)
When user "participant1" sends message "Message 1" to room "group room" with 201
Then user "participant1" is participant of room "group room" (v4)
| unreadMessages |
| 0 |
And user "participant2" is participant of room "group room" (v4)
| unreadMessages |
| 1 |
Scenario: sending several messages clears unread counter for sender
Given user "participant1" creates room "group room" (v4)
| roomType | 2 |
| roomName | room |
And user "participant1" adds user "participant2" to room "group room" with 200 (v4)
When user "participant1" sends message "Message 1" to room "group room" with 201
And user "participant1" sends message "Message 2" to room "group room" with 201
And user "participant1" sends message "Message 3" to room "group room" with 201
Then user "participant1" is participant of room "group room" (v4)
| unreadMessages |
| 0 |
And user "participant2" is participant of room "group room" (v4)
| unreadMessages |
| 3 |
Scenario: sending a message with previously unread messages clears unread counter for sender
Given user "participant1" creates room "group room" (v4)
| roomType | 2 |
| roomName | room |
And user "participant1" adds user "participant2" to room "group room" with 200 (v4)
And user "participant2" sends message "Message 1" to room "group room" with 201
And user "participant2" sends message "Message 2" to room "group room" with 201
When user "participant1" sends message "Message 3" to room "group room" with 201
Then user "participant1" is participant of room "group room" (v4)
| unreadMessages |
| 0 |
And user "participant2" is participant of room "group room" (v4)
| unreadMessages |
| 1 |
Scenario: reading all messages clears unread counter for reader
Given user "participant1" creates room "group room" (v4)
| roomType | 2 |
| roomName | room |
And user "participant1" adds user "participant2" to room "group room" with 200 (v4)
And user "participant1" sends message "Message 1" to room "group room" with 201
And user "participant1" sends message "Message 2" to room "group room" with 201
And user "participant1" sends message "Message 3" to room "group room" with 201
When user "participant2" reads message "Message 3" in room "group room" with 200
Then user "participant2" is participant of room "group room" (v4)
| unreadMessages |
| 0 |
Scenario: reading some messages reduces unread counter for reader
Given user "participant1" creates room "group room" (v4)
| roomType | 2 |
| roomName | room |
And user "participant1" adds user "participant2" to room "group room" with 200 (v4)
And user "participant1" sends message "Message 1" to room "group room" with 201
And user "participant1" sends message "Message 2" to room "group room" with 201
And user "participant1" sends message "Message 3" to room "group room" with 201
When user "participant2" reads message "Message 2" in room "group room" with 200
Then user "participant2" is participant of room "group room" (v4)
| unreadMessages |
| 1 |
Scenario: replies are taken into account in unread counter
Given user "participant1" creates room "group room" (v4)
| roomType | 2 |
| roomName | room |
And user "participant1" adds user "participant2" to room "group room" with 200 (v4)
And user "participant1" sends message "Message 1" to room "group room" with 201
When user "participant1" sends reply "Message 1-1" on message "Message 1" to room "group room" with 201
Then user "participant1" is participant of room "group room" (v4)
| unreadMessages |
| 0 |
And user "participant2" is participant of room "group room" (v4)
| unreadMessages |
| 2 |
Scenario: rich object messages are taken into account in unread counter
Given user "participant1" creates room "group room" (v4)
| roomType | 2 |
| roomName | room |
And user "participant1" adds user "participant2" to room "group room" with 200 (v4)
When user "participant1" shares rich-object "call" "R4nd0mT0k3n" '{"name":"Another room","call-type":"group"}' to room "group room" with 201 (v1)
Then user "participant1" is participant of room "group room" (v4)
| unreadMessages |
| 0 |
And user "participant2" is participant of room "group room" (v4)
| unreadMessages |
| 1 |
Scenario: shared file messages are taken into account in unread counter
Given user "participant1" creates room "group room" (v4)
| roomType | 2 |
| roomName | room |
And user "participant1" adds user "participant2" to room "group room" with 200 (v4)
When user "participant1" shares "welcome.txt" with room "group room"
# Unread counter for sender is not cleared in this case, as it is not
# possible to know whether the file was shared from Talk, which could clear
# the counter, or from the Files app, which should not clear it.
Then user "participant1" is participant of room "group room" (v4)
| unreadMessages |
| 1 |
And user "participant2" is participant of room "group room" (v4)
| unreadMessages |
| 1 |
Scenario: system messages are not taken into account in unread counter
Given user "participant1" creates room "group room" (v4)
| roomType | 2 |
| roomName | room |
And user "participant1" adds user "participant2" to room "group room" with 200 (v4)
When user "participant1" makes room "group room" private with 200 (v4)
Then user "participant1" is participant of room "group room" (v4)
| unreadMessages |
| 0 |
And user "participant2" is participant of room "group room" (v4)
| unreadMessages |
| 0 |
Loading…
Cancel
Save