Skip to content

Commit e17459c

Browse files
committed
wip:testing ci
Signed-off-by: grnd-alt <[email protected]>
1 parent d20601a commit e17459c

2 files changed

Lines changed: 103 additions & 0 deletions

File tree

tests/integration/features/bootstrap/FederationContext.php

Lines changed: 91 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,50 @@ 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/' . $found['id'], [], $user, $server);
265+
$stacks = $this->getOCSData();
266+
$cardTitleFound = false;
267+
$cardFound = false;
268+
$assignedUsers = [];
269+
foreach ($stacks as $stack) {
270+
foreach ($stack['cards'] as $card) {
271+
if ($card['title'] === $cardTitle) {
272+
$cardTitleFound = true;
273+
foreach ($card['assignedUsers'] as $assigned) {
274+
$assignedUsers[] = $assigned;
275+
if ($assigned['participant']['displayname'] === $assignedUser) {
276+
$cardFound = true;
277+
break 3;
278+
}
279+
}
280+
}
281+
}
282+
}
283+
284+
Assert::assertTrue($cardTitleFound, "Card '{$cardTitle}' not found on board '{$boardTitle}'");
285+
286+
Assert::assertTrue($cardFound, "Assigned user '{$assignedUser}' not found on card '{$cardTitle}' on board '{$boardTitle}' found '" . implode(', ', $assignedUsers) . "'");
287+
}
288+
289+
290+
245291
/**
246292
* @When /^user "([^"]*)" on "([^"]*)" creates a stack "([^"]*)" on the federated board$/
247293
*/
@@ -280,6 +326,7 @@ public function userCreatesCardOnFederatedBoard(string $user, string $server, st
280326
'stackId' => $stackId,
281327
'boardId' => $federatedBoard['id'],
282328
], $user, $server);
329+
$this->card = $this->getOCSData();
283330
}
284331

285332
/**
@@ -342,4 +389,48 @@ private function findFederatedBoard(string $user, string $server): array {
342389

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

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 "Assigning 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 "Assigning Board"
33+

0 commit comments

Comments
 (0)