Skip to content

Commit

Permalink
tests(reminder): Add integration tests for reminder functionality
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Aug 2, 2023
1 parent f1d78bb commit 86d7538
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 6 deletions.
51 changes: 47 additions & 4 deletions tests/integration/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -1685,6 +1685,49 @@ public function userSendsMessageToRoom(string $user, string $sendingMode, string
}
}

/**
* @Then /^user "([^"]*)" sets reminder for message ("[^"]*"|'[^']*') in room "([^"]*)" for time (\d+) with (\d+)(?: \((v1)\))?$/
*
* @param string $user
* @param string $setOrDelete
* @param string $message
* @param string $identifier
* @param string $statusCode
* @param string $apiVersion
*/
public function userSetsReminder(string $user, string $message, string $identifier, int $timestamp, int $statusCode, string $apiVersion = 'v1'): void {
$message = substr($message, 1, -1);

$this->setCurrentUser($user);
$this->sendRequest(
'POST',
'/apps/spreed/api/' . $apiVersion . '/chat/' . self::$identifierToToken[$identifier] . '/' . self::$textToMessageId[$message] . '/reminder',
new TableNode([['timestamp', $timestamp]])
);
$this->assertStatusCode($this->response, $statusCode);
}

/**
* @Then /^user "([^"]*)" deletes reminder for message ("[^"]*"|'[^']*') in room "([^"]*)" with (\d+)(?: \((v1)\))?$/
*
* @param string $user
* @param string $setOrDelete
* @param string $message
* @param string $identifier
* @param string $statusCode
* @param string $apiVersion
*/
public function userDeletesReminder(string $user, string $message, string $identifier, string $statusCode, string $apiVersion = 'v1'): void {
$message = substr($message, 1, -1);

$this->setCurrentUser($user);
$this->sendRequest(
'DELETE',
'/apps/spreed/api/' . $apiVersion . '/chat/' . self::$identifierToToken[$identifier] . '/' . self::$textToMessageId[$message] . '/reminder'
);
$this->assertStatusCode($this->response, $statusCode);
}

/**
* @Then /^user "([^"]*)" shares rich-object "([^"]*)" "([^"]*)" '([^']*)' to room "([^"]*)" with (\d+)(?: \((v1)\))?$/
*
Expand Down Expand Up @@ -3440,13 +3483,13 @@ public function userShareLastNotificationFile(string $user, string $firstLast, s
}

/**
* @When /^run transcript background jobs$/
* @When /^run "([^"]*)" background jobs$/
*/
public function runTranscriptBackgroundJobs(): void {
$this->runOcc(['background-job:list', '--output=json_pretty', '--class=OC\SpeechToText\TranscriptionJob']);
public function runReminderBackgroundJobs(string $class): void {
$this->runOcc(['background-job:list', '--output=json_pretty', '--class=' . $class]);
$list = json_decode($this->lastStdOut, true, 512, JSON_THROW_ON_ERROR);

Assert::assertNotEmpty($list, 'List of OC\SpeechToText\TranscriptionJob should not be empty');
Assert::assertNotEmpty($list, 'List of ' . $class . ' should not be empty');

foreach ($list as $job) {
$this->runOcc(['background-job:execute', (string) $job['id']]);
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/features/callapi/recording.feature
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ Feature: callapi/recording
And user "participant1" is participant of the following unordered rooms (v4)
| type | name | callRecording |
| 2 | room1 | 0 |
When run transcript background jobs
When run "OC\SpeechToText\TranscriptionJob" background jobs
Then user "participant1" has the following notifications
| app | object_type | object_id | subject | message |
| spreed | recording | room1 | Transcript now available | The transcript for the call in room1 was uploaded to /Talk/Recording/ROOM(room1)/join_call.txt. |
Expand All @@ -470,7 +470,7 @@ Feature: callapi/recording
And user "participant1" is participant of the following unordered rooms (v4)
| type | name | callRecording |
| 2 | room1 | 0 |
When run transcript background jobs
When run "OC\SpeechToText\TranscriptionJob" background jobs
Then user "participant1" has the following notifications
| app | object_type | object_id | subject | message |
| spreed | recording | room1 | Failed to transcript call recording | The server failed to transcript the recording at /Talk/Recording/ROOM(room1)/leave_call.ogg for the call in room1. Please reach out to the administration. |
Expand Down
127 changes: 127 additions & 0 deletions tests/integration/features/chat-2/reminder.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
Feature: chat-2/reminder

Background:
Given user "participant1" exists
Given user "participant2" exists

Scenario: Reminder in one-to-one chat (and sender is deleted)
Given user "participant1" creates room "room" (v4)
| roomType | 1 |
| invite | participant2 |
And user "participant2" joins room "room" with 200 (v4)
And user "participant1" sends message "Message 1" to room "room" with 201
When user "participant1" sets reminder for message "Message 1" in room "room" for time 1234567 with 201 (v1)
And user "participant2" sets reminder for message "Message 1" in room "room" for time 1234567 with 201 (v1)
And user "participant1" has the following notifications
| app | object_type | object_id | subject |
And user "participant2" has the following notifications
| app | object_type | object_id | subject |
And run "OCA\Talk\BackgroundJob\ChatMessageReminder" background jobs
Then user "participant1" has the following notifications
| app | object_type | object_id | subject |
| spreed | reminder | room/Message 1 | Reminder: You in private conversation participant2-displayname |
And user "participant2" has the following notifications
| app | object_type | object_id | subject |
| spreed | reminder | room/Message 1 | Reminder: participant1-displayname in private conversation |
When user "participant1" is deleted
And user "participant2" has the following notifications
| app | object_type | object_id | subject |
| spreed | reminder | room/Message 1 | Reminder: A deleted user in private conversation participant1-displayname |
And user "participant2" deletes reminder for message "Message 1" in room "room" with 200 (v1)
And user "participant2" has the following notifications
| app | object_type | object_id | subject |

Scenario: Reminder in one-to-one chat recipient is deleted
Given user "participant1" creates room "room" (v4)
| roomType | 1 |
| invite | participant2 |
And user "participant2" joins room "room" with 200 (v4)
And user "participant1" sends message "Message 1" to room "room" with 201
When user "participant1" sets reminder for message "Message 1" in room "room" for time 1234567 with 201 (v1)
And user "participant2" sets reminder for message "Message 1" in room "room" for time 1234567 with 201 (v1)
And user "participant1" has the following notifications
| app | object_type | object_id | subject |
And user "participant2" has the following notifications
| app | object_type | object_id | subject |
And run "OCA\Talk\BackgroundJob\ChatMessageReminder" background jobs
Then user "participant1" has the following notifications
| app | object_type | object_id | subject |
| spreed | reminder | room/Message 1 | Reminder: You in private conversation participant2-displayname |
And user "participant2" has the following notifications
| app | object_type | object_id | subject |
| spreed | reminder | room/Message 1 | Reminder: participant1-displayname in private conversation |
When user "participant2" is deleted
And user "participant1" has the following notifications
| app | object_type | object_id | subject |
| spreed | reminder | room/Message 1 | Reminder: You in private conversation participant2-displayname |
And user "participant1" deletes reminder for message "Message 1" in room "room" with 200 (v1)
And user "participant1" has the following notifications
| app | object_type | object_id | subject |

Scenario: Reminder on user message
Given user "participant1" creates room "room" (v4)
| roomType | 3 |
| roomName | room |
And user "participant1" adds user "participant2" to room "room" with 200 (v4)
And user "participant2" joins room "room" with 200 (v4)
And user "participant1" sends message "Message 1" to room "room" with 201
When user "participant1" sets reminder for message "Message 1" in room "room" for time 1234567 with 201 (v1)
And user "participant2" sets reminder for message "Message 1" in room "room" for time 1234567 with 201 (v1)
And user "participant1" has the following notifications
| app | object_type | object_id | subject |
And user "participant2" has the following notifications
| app | object_type | object_id | subject |
And run "OCA\Talk\BackgroundJob\ChatMessageReminder" background jobs
Then user "participant1" has the following notifications
| app | object_type | object_id | subject |
| spreed | reminder | room/Message 1 | Reminder: You in conversation room |
And user "participant2" has the following notifications
| app | object_type | object_id | subject |
| spreed | reminder | room/Message 1 | Reminder: participant1-displayname in conversation room |
When user "participant1" is deleted
And user "participant2" has the following notifications
| app | object_type | object_id | subject |
| spreed | reminder | room/Message 1 | Reminder: A deleted user in conversation room |
And user "participant2" deletes reminder for message "Message 1" in room "room" with 200 (v1)
And user "participant2" has the following notifications
| app | object_type | object_id | subject |

Scenario: Reminder on anonymous guest message
Given user "participant1" creates room "room" (v4)
| roomType | 3 |
| roomName | room |
And user "guest" joins room "room" with 200 (v4)
And user "guest" sends message "Message 1" to room "room" with 201
When user "participant1" sets reminder for message "Message 1" in room "room" for time 1234567 with 201 (v1)
And user "participant2" sets reminder for message "Message 1" in room "room" for time 1234567 with 404 (v1)
And user "participant1" has the following notifications
| app | object_type | object_id | subject |
And user "participant2" has the following notifications
| app | object_type | object_id | subject |
And run "OCA\Talk\BackgroundJob\ChatMessageReminder" background jobs
Then user "participant1" has the following notifications
| app | object_type | object_id | subject |
| spreed | reminder | room/Message 1 | Reminder: A guest in conversation room |
And user "participant2" has the following notifications
| app | object_type | object_id | subject |
And user "participant1" deletes reminder for message "Message 1" in room "room" with 200 (v1)
And user "participant1" has the following notifications
| app | object_type | object_id | subject |

Scenario: Reminder on named guest message
Given user "participant1" creates room "room" (v4)
| roomType | 3 |
| roomName | room |
And user "guest" joins room "room" with 200 (v4)
And guest "guest" sets name to "FooBar" in room "room" with 200
And user "guest" sends message "Message 1" to room "room" with 201
When user "participant1" sets reminder for message "Message 1" in room "room" for time 1234567 with 201 (v1)
And user "participant1" has the following notifications
| app | object_type | object_id | subject |
And run "OCA\Talk\BackgroundJob\ChatMessageReminder" background jobs
Then user "participant1" has the following notifications
| app | object_type | object_id | subject |
| spreed | reminder | room/Message 1 | Reminder: FooBar (guest) in conversation room |
And user "participant1" deletes reminder for message "Message 1" in room "room" with 200 (v1)
And user "participant1" has the following notifications
| app | object_type | object_id | subject |

0 comments on commit 86d7538

Please sign in to comment.