Skip to content

Commit d93fe70

Browse files
committed
wip:testing ci
Signed-off-by: grnd-alt <git@belakkaf.net>
1 parent d20601a commit d93fe70

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

tests/integration/features/bootstrap/FederationContext.php

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class FederationContext implements Context {
3232
private ?array $board = null;
3333
/** @var array|null Last stack created/fetched */
3434
private ?array $stack = null;
35+
/** @var array|null Last card created/fetched */
36+
private ?array $card = null;
3537

3638
/** @BeforeScenario */
3739
public function gatherContexts(BeforeScenarioScope $scope) {
@@ -242,6 +244,46 @@ public function userOnShouldNotSeeBoard(string $user, string $server, string $bo
242244
Assert::assertFalse($found, "Board '{$boardTitle}' should not be visible for user '{$user}' on {$server}");
243245
}
244246

247+
/**
248+
* @Then /^user "([^"]*)" on "([^"]*)" should see assigned user "([^"]*)" on card "([^"]*)" on the federated board "([^"]*)"$/
249+
*/
250+
public function userOnShouldSeeAssigned(string $user, string $server, string $assignedUser, string $cardTitle, string $boardTitle) {
251+
$this->sendOCSRequest('GET', '/apps/deck/api/v1.0/boards', [], $user, $server);
252+
$boards = $this->getOCSData();
253+
254+
$found = false;
255+
foreach ($boards as $board) {
256+
if ($board['title'] === $boardTitle) {
257+
$found = $board;
258+
break;
259+
}
260+
}
261+
262+
Assert::assertNotNull($found, "Board '{$boardTitle}' not found for user '{$user}' on {$server}");
263+
264+
$this->sendOCSRequest('GET', '/apps/deck/api/v1.0/stacks?boardId=' . $found['id'], [], $user, $server);
265+
$stacks = $this->getOCSData();
266+
$cardFound = false;
267+
$assignedUsers = [];
268+
foreach ($stacks as $stack) {
269+
foreach ($stack['cards'] as $card) {
270+
if ($card['title'] === $cardTitle) {
271+
foreach ($card['assignedUsers'] as $assigned) {
272+
$assignedUsers[] = $assigned['userId'];
273+
if ($assigned['userId'] === $assignedUser) {
274+
$cardFound = true;
275+
break 3;
276+
}
277+
}
278+
}
279+
}
280+
}
281+
282+
Assert::assertTrue($cardFound, "Assigned user '{$assignedUser}' not found on card '{$cardTitle}' on board '{$boardTitle}' found '" . implode(', ', $assignedUsers) . "'");
283+
}
284+
285+
286+
245287
/**
246288
* @When /^user "([^"]*)" on "([^"]*)" creates a stack "([^"]*)" on the federated board$/
247289
*/
@@ -280,6 +322,7 @@ public function userCreatesCardOnFederatedBoard(string $user, string $server, st
280322
'stackId' => $stackId,
281323
'boardId' => $federatedBoard['id'],
282324
], $user, $server);
325+
$this->card = $this->getOCSData();
283326
}
284327

285328
/**
@@ -342,4 +385,47 @@ private function findFederatedBoard(string $user, string $server): array {
342385

343386
throw new \RuntimeException('No federated board "' . $expectedTitle . '" found for user ' . $user . ' on ' . $server);
344387
}
388+
389+
/**
390+
* @When /^user "([^"]*)" on "([^"]*)" assigns user "([^"]*)" to card "([^"]*)" on the federated board$/
391+
*
392+
* Assign a user to a card by card title on the federated board.
393+
*
394+
* @param string $user The acting user
395+
* @param string $server LOCAL or REMOTE
396+
* @param string $userId The user id to assign
397+
* @param string $cardTitle The card title
398+
*/
399+
public function assignUserToCard(string $user, string $server, string $userId, string $cardTitle) {
400+
$federatedBoard = $this->findFederatedBoard($user, $server);
401+
Assert::assertNotNull($this->card, 'No card created in this scenario');
402+
Assert::assertEquals($cardTitle, $this->card['title'], 'Last card title does not match');
403+
$cardId = $this->card['id'];
404+
$data = [
405+
'userId' => $userId,
406+
'type' => 0,
407+
];
408+
$this->sendOCSRequest('POST', "/apps/deck/api/v1.0/cards/{$cardId}/assignUser?boardId={$federatedBoard['id']}", $data, $user, $server);
409+
}
410+
411+
/**
412+
* Unassign a user from a card using the CardOcsController OCS route.
413+
*
414+
* @param string $user The acting user
415+
* @param string $server LOCAL or REMOTE
416+
* @param int $cardId The card id
417+
* @param string $userId The user id to unassign
418+
* @param int|null $boardId The board id (required for federated boards)
419+
* @param int $type The assignment type (default 0)
420+
*/
421+
public function unassignUserFromCard(string $user, string $server, int $cardId, string $userId, ?int $boardId = null, int $type = 0) {
422+
$data = [
423+
'userId' => $userId,
424+
'type' => $type,
425+
];
426+
if ($boardId !== null) {
427+
$data['boardId'] = $boardId;
428+
}
429+
$this->sendOCSRequest('POST', "/apps/deck/api/v1.0/cards/{$cardId}/unAssignUser", $data, $user, $server);
430+
}
345431
}

tests/integration/features/federation/cards.feature

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,15 @@ Feature: Federation card operations
1919
| permissionEdit | 1 |
2020
And user "admin" on "REMOTE" creates a card "Remote Card" on stack "ToDo" on the federated board
2121
Then the OCS response should have status code "200"
22+
23+
Scenario: Assign user on a federated board
24+
Given using server "LOCAL"
25+
And acting as user "admin"
26+
And creates a board named "Card Board" with color "ff0000"
27+
And create a stack named "ToDo"
28+
When user "admin" on "LOCAL" shares the board with federated user "admin"
29+
| permissionEdit | 1 |
30+
And user "admin" on "REMOTE" creates a card "Remote Card" on stack "ToDo" on the federated board
31+
And user "admin" on "REMOTE" assigns user "admin" to card "Remote Card" on the federated board
32+
Then user "admin" on "LOCAL" should see assigned user "admin" on card "Remote Card" on the federated board
33+

0 commit comments

Comments
 (0)