Skip to content

Commit 9f797af

Browse files
nickvergessenmiaulalala
authored andcommitted
test: Fix team and group mention test
Signed-off-by: Joas Schilling <[email protected]>
1 parent 7a1ef5e commit 9f797af

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

tests/integration/features/bootstrap/FeatureContext.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1963,6 +1963,13 @@ public function userSchedulesMessageToRoom(string $user, string $identifier, int
19631963
$row['threadId'] = self::$titleToThreadId[$row['threadId']];
19641964
}
19651965

1966+
if (str_contains($row['message'], '@"TEAM_ID(')) {
1967+
$result = preg_match('/TEAM_ID\(([^)]+)\)/', $row['message'], $matches);
1968+
if ($result) {
1969+
$row['message'] = str_replace($matches[0], 'team/' . self::getTeamIdForLabel($this->currentServer, $matches[1]), $row['message']);
1970+
}
1971+
}
1972+
19661973
$this->setCurrentUser($user);
19671974
$this->sendRequest(
19681975
'POST',
@@ -2054,6 +2061,13 @@ public function userSeesTheFollowingScheduledMessagesInRoom(string $user, string
20542061

20552062
$expected = $formData->getColumnsHash();
20562063
foreach ($expected as &$row) {
2064+
if (str_contains($row['message'], '@"TEAM_ID(')) {
2065+
$result = preg_match('/TEAM_ID\(([^)]+)\)/', $row['message'], $matches);
2066+
if ($result) {
2067+
$row['message'] = str_replace($matches[0], 'team/' . self::getTeamIdForLabel($this->currentServer, $matches[1]), $row['message']);
2068+
}
2069+
}
2070+
20572071
$row['id'] = self::$textToMessageId[$row['message']];
20582072
if ($row['sendAt'] !== '0') {
20592073
$row['sendAt'] = self::$messageIdToTimestamp[$row['id']];
@@ -2869,6 +2883,10 @@ protected function compareDataResponse(?TableNode $formData = null): void {
28692883
if ($result) {
28702884
$expected[$i]['messageParameters'] = str_replace($matches[0], '"' . self::$questionToPollId[$matches[1]] . '"', $expected[$i]['messageParameters']);
28712885
}
2886+
$result = preg_match('/TEAM_ID\(([^)]+)\)/', $expected[$i]['messageParameters'], $matches);
2887+
if ($result) {
2888+
$expected[$i]['messageParameters'] = str_replace($matches[0], self::getTeamIdForLabel($this->currentServer, $matches[1]), $expected[$i]['messageParameters']);
2889+
}
28722890
if (isset($messages[$i]['messageParameters']['object']['icon-url'])) {
28732891
$result = preg_match('/"\{VALIDATE_ICON_URL_PATTERN\}"/', $expected[$i]['messageParameters'], $matches);
28742892
if ($result) {

tests/integration/features/chat-4/scheduled-messages.feature

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -529,23 +529,20 @@ Feature: chat-4/scheduling
529529

530530
Scenario: Schedule a message mentioning a group
531531
Given group "group" exists
532-
Given team "team" exists
533-
Given user "participant3" exists
534-
Given user "participant4" exists
535-
And user "participant3" is member of group "group"
536-
And user "participant4" is member of team "team"
532+
And set display name of group "group" to "group-displayname"
533+
Given User "participant1" creates team "team"
537534
And user "participant1" adds group "group" to room "room" with 200 (v4)
538535
And user "participant1" adds team "team" to room "room" with 200 (v4)
539536
When user "participant1" schedules a message to room "room" with 201
540-
| message | Message 1 @group |
541-
| sendAt | {NOW} |
537+
| message | Message 1 @"group/group" |
538+
| sendAt | {NOW} |
542539
And user "participant1" schedules a message to room "room" with 201
543-
| message | Message 2 @team |
544-
| sendAt | {NOW} |
540+
| message | Message 2 @"TEAM_ID(team)" |
541+
| sendAt | {NOW} |
545542
Then user "participant1" sees the following scheduled messages in room "room" with 200
546-
| id | actorType | actorId | threadId | parent | message | messageType | sendAt | silent |
547-
| Message 1 @group | users | participant1 | 0 | null | Message 1 @group | comment | {NOW} | false |
548-
| Message 2 @team | users | participant1 | 0 | null | Message 2 @team | comment | {NOW} | false |
543+
| id | actorType | actorId | threadId | parent | message | messageType | sendAt | silent |
544+
| Message 1 @"group/group" | users | participant1 | 0 | null | Message 1 @"group/group" | comment | {NOW} | false |
545+
| Message 2 @"TEAM_ID(team)" | users | participant1 | 0 | null | Message 2 @"TEAM_ID(team)" | comment | {NOW} | false |
549546
And user "participant1" is participant of the following rooms (v4)
550547
| id | type | hasScheduledMessages |
551548
| room | 2 | 2 |
@@ -556,7 +553,7 @@ Feature: chat-4/scheduling
556553
| id | type | hasScheduledMessages |
557554
| room | 2 | 0 |
558555
Then user "participant2" sees the following messages in room "room" with 200
559-
| room | actorType | actorId | actorDisplayName | messageType | message | messageParameters |
560-
| room | users | participant1 | participant1-displayname | comment | Message 2 {mention-team} | {"mention-team":{"type":"team","id":"team","name":"team-displayname","mention-id":"team"}} |
561-
| room | users | participant1 | participant1-displayname | comment | Message 1 {mention-group} | {"mention-group":{"type":"group","id":"group","name":"group-displayname","mention-id":"group"}} |
562-
| room | users | participant2 | participant2-displayname | comment | Message | [] |
556+
| room | actorType | actorId | actorDisplayName | messageType | message | messageParameters |
557+
| room | users | participant1 | participant1-displayname | comment | Message 2 {mention-team1} | {"mention-team1":{"type":"circle","id":"TEAM_ID(team)","name":"team","link":"","mention-id":"team\/TEAM_ID(team)"}} |
558+
| room | users | participant1 | participant1-displayname | comment | Message 1 {mention-group1} | {"mention-group1":{"type":"user-group","id":"group","name":"group-displayname","mention-id":"group\/group"}} |
559+
| room | users | participant2 | participant2-displayname | comment | Message | [] |

0 commit comments

Comments
 (0)