summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/features/bootstrap/FeatureContext.php1
-rw-r--r--tests/integration/features/chat/bots.feature21
-rwxr-xr-xtests/integration/run.sh35
-rw-r--r--tests/php/Notification/NotifierTest.php7
4 files changed, 45 insertions, 19 deletions
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php
index b854cd26e..2881f3b9a 100644
--- a/tests/integration/features/bootstrap/FeatureContext.php
+++ b/tests/integration/features/bootstrap/FeatureContext.php
@@ -2307,6 +2307,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
// replies; this is needed to get special messages not explicitly
// sent like those for shared files.
self::$textToMessageId[$message['message']] = $message['id'];
+ self::$messageIdToText[$message['id']] = $message['message'];
if ($message['message'] === '{file}' && isset($message['messageParameters']['file']['name'])) {
self::$textToMessageId['shared::file::' . $message['messageParameters']['file']['name']] = $message['id'];
self::$messageIdToText[$message['id']] = 'shared::file::' . $message['messageParameters']['file']['name'];
diff --git a/tests/integration/features/chat/bots.feature b/tests/integration/features/chat/bots.feature
index fb540a613..4e16e6757 100644
--- a/tests/integration/features/chat/bots.feature
+++ b/tests/integration/features/chat/bots.feature
@@ -204,31 +204,36 @@ Feature: chat/bots
# Unchanged from above
Scenario: Bot with response only feature
- Given invoking occ with "talk:bot:install Bot Secret1234567890123456789012345678901234567890 https://localhost/bot1 --feature=response"
+ Given invoking occ with "talk:bot:install Bot1 Secret1234567890123456789012345678901234567890 https://localhost/bot1 --feature=response"
And the command was successful
And read bot ids from OCC
And user "participant1" creates room "room1" (v4)
| roomType | 2 |
| roomName | room1 |
- And invoking occ with "talk:bot:setup BOT(Bot) ROOM(room1)"
+ And invoking occ with "talk:bot:setup BOT(Bot1) ROOM(room1)"
And the command was successful
+ And user "participant1" sets notifications to all for room "room1" (v4)
And user "participant1" sends message "Message 1" to room "room1" with 201
- When Bot "Bot" sends a message for room "room1" with 201 (v1)
+ When Bot "Bot1" sends a message for room "room1" with 201 (v1)
| secret | Secret1234567890123456789012345678901234567890 |
| message | Response 1 |
| replyTo | Message 1 |
- When Bot "Bot" sends a reaction for room "room1" with 201 (v1)
+ When Bot "Bot1" sends a reaction for room "room1" with 201 (v1)
| secret | Secret1234567890123456789012345678901234567890 |
| messageId | Message 1 |
| reaction | 👍 |
Then user "participant1" sees the following messages in room "room1" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | parentMessage |
- | room1 | bots | BOT(Bot) | Bot (Bot) | Response 1 | [] | Message 1 |
+ | room1 | bots | BOT(Bot1) | Bot1 (Bot) | Response 1 | [] | Message 1 |
| room1 | users | participant1 | participant1-displayname | Message 1 | [] | |
+ And user participant1 has the following notifications
+ | app | object_type | object_id | subject |
+ | spreed | chat | room1/Message 1 | Bot1 (Bot) reacted with 👍 to your message in conversation room1 |
+ | spreed | chat | room1/Response 1 | Bot1 (Bot) replied to your message in conversation room1 |
Then user "participant1" retrieve reactions "👍" of message "Message 1" in room "room1" with 200
- | actorType | actorId | actorDisplayName | reaction |
- | bots | BOT(Bot) | Bot (Bot) | 👍 |
- When Bot "Bot" removes a reaction for room "room1" with 200 (v1)
+ | actorType | actorId | actorDisplayName | reaction |
+ | bots | BOT(Bot1) | Bot1 (Bot) | 👍 |
+ When Bot "Bot1" removes a reaction for room "room1" with 200 (v1)
| secret | Secret1234567890123456789012345678901234567890 |
| messageId | Message 1 |
| reaction | 👍 |
diff --git a/tests/integration/run.sh b/tests/integration/run.sh
index 48df4dbfd..f0c71a24b 100755
--- a/tests/integration/run.sh
+++ b/tests/integration/run.sh
@@ -1,5 +1,7 @@
#!/usr/bin/env bash
+PROCESS_ID=$$
+
APP_NAME=spreed
NOTIFICATIONS_BRANCH="master"
GUESTS_BRANCH="master"
@@ -17,23 +19,29 @@ echo ''
echo -e "\033[0;36m#\033[0m"
echo -e "\033[0;36m# Starting PHP webserver\033[0m"
echo -e "\033[0;36m#\033[0m"
-PHP_CLI_SERVER_WORKERS=3 php -S localhost:8080 -t ${ROOT_DIR} &
+
+echo "" > phpserver.log
+PHP_CLI_SERVER_WORKERS=3 php -S localhost:8080 -t ${ROOT_DIR} &> phpserver.log &
PHPPID1=$!
echo -e "Running on process ID: \033[1;35m$PHPPID1\033[0m"
-# also kill php process in case of ctrl+c
-trap 'pkill -P $PHPPID1; kill -TERM $PHPPID1; wait $PHPPID1' TERM
+# Output filtered php server logs
+tail -f phpserver.log | grep --line-buffered -v -E ":[0-9]+ Accepted$" | grep --line-buffered -v -E ":[0-9]+ Closing$" &
# The federated server is started and stopped by the tests themselves
PORT_FED=8180
export PORT_FED
-php -S localhost:${PORT_FED} -t ${ROOT_DIR} &
+echo "" > phpserver_fed.log
+php -S localhost:${PORT_FED} -t ${ROOT_DIR} &> phpserver_fed.log &
PHPPID2=$!
echo -e "Running on process ID: \033[1;35m$PHPPID2\033[0m"
-# also kill php process in case of ctrl+c
-trap 'pkill -P $PHPPID2; kill -TERM $PHPPID2; wait $PHPPID2' TERM
+# Output filtered federated php server logs
+tail -f phpserver_fed.log | grep --line-buffered -v -E ":[0-9]+ Accepted$" | grep --line-buffered -v -E ":[0-9]+ Closing$" &
+
+# Kill all sub-processes in case of ctrl+c
+trap 'pkill -P $PHPPID1; pkill -P $PHPPID2; pkill -P $PROCESS_ID; wait $PHPPID1; wait $PHPPID2;' INT TERM
NEXTCLOUD_ROOT_DIR=${ROOT_DIR}
export NEXTCLOUD_ROOT_DIR
@@ -100,10 +108,17 @@ echo ''
echo -e "\033[0;36m#\033[0m"
echo -e "\033[0;36m# Stopping PHP webserver\033[0m"
echo -e "\033[0;36m#\033[0m"
-pkill -P $PHPPID1
-kill $PHPPID1
-pkill -P $PHPPID2
-kill $PHPPID2
+
+# Kill parent PHP processes
+kill -TERM $PHPPID1;
+kill -TERM $PHPPID2;
+
+# Kill child PHP processes
+pkill -P $PHPPID1;
+pkill -P $PHPPID2;
+
+# Kill child processes of this script (e.g. tail)
+pkill -P $PROCESS_ID;
echo ''
echo -e "\033[0;36m#\033[0m"
diff --git a/tests/php/Notification/NotifierTest.php b/tests/php/Notification/NotifierTest.php
index ec40c89ed..96b6fa6b7 100644
--- a/tests/php/Notification/NotifierTest.php
+++ b/tests/php/Notification/NotifierTest.php
@@ -30,6 +30,7 @@ use OCA\Talk\Exceptions\RoomNotFoundException;
use OCA\Talk\GuestManager;
use OCA\Talk\Manager;
use OCA\Talk\Model\Attendee;
+use OCA\Talk\Model\BotServerMapper;
use OCA\Talk\Model\Message;
use OCA\Talk\Notification\Notifier;
use OCA\Talk\Participant;
@@ -91,6 +92,8 @@ class NotifierTest extends TestCase {
protected ?Notifier $notifier = null;
/** @var AddressHandler|MockObject */
protected $addressHandler;
+ /** @var BotServerMapper|MockObject */
+ protected $botServerMapper;
public function setUp(): void {
parent::setUp();
@@ -113,6 +116,7 @@ class NotifierTest extends TestCase {
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->definitions = $this->createMock(Definitions::class);
$this->addressHandler = $this->createMock(AddressHandler::class);
+ $this->botServerMapper = $this->createMock(BotServerMapper::class);
$this->notifier = new Notifier(
$this->lFactory,
@@ -132,7 +136,8 @@ class NotifierTest extends TestCase {
$this->rootFolder,
$this->timeFactory,
$this->definitions,
- $this->addressHandler
+ $this->addressHandler,
+ $this->botServerMapper,
);
}