fix: Limit card activities for deleted cards

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2024-01-04 14:01:49 +01:00
parent f4791aa4a4
commit ce820e19c4
5 changed files with 56 additions and 2 deletions

View File

@@ -17,9 +17,9 @@ class BoardContext implements Context {
/** @var array last card response */
private $card = null;
private array $storedCards = [];
private ?array $activities = null;
/** @var ServerContext */
private $serverContext;
private ServerContext $serverContext;
/** @BeforeScenario */
public function gatherContexts(BeforeScenarioScope $scope) {
@@ -303,4 +303,23 @@ class BoardContext implements Context {
public function deleteTheBoard() {
$this->requestContext->sendJSONrequest('DELETE', '/index.php/apps/deck/boards/' . $this->board['id']);
}
/**
* @Given /^get the activities for the last card$/
*/
public function getActivitiesForTheLastCard() {
$card = $this->getLastUsedCard();
$this->requestContext->sendOCSRequest('GET', '/apps/activity/api/v2/activity/filter?format=json&type=deck&since=0&object_type=deck_card&object_id=' . $card['id'] . '&limit=50');
$this->activities = json_decode((string)$this->getResponse()->getBody(), true)['ocs']['data'] ?? null;
}
/**
* @Then the fetched activities should have :count entries
*/
public function theFetchedActivitiesShouldHaveEntries($count) {
Assert::assertEquals($count, count($this->activities ?? []));
}
}

View File

@@ -103,8 +103,13 @@ Feature: decks
And uploads an attachment to the last used card
And remember the last attachment as "my-attachment"
And post a comment with content "My first comment" on the card
When get the activities for the last card
Then the fetched activities should have 3 entries
And delete the card
When get the activities for the last card
Then the fetched activities should have 0 entries
When fetching the attachment "my-attachment" for the card "deletedCard"
Then the response should have a status code 403