tests: Add integration tests for deleted boards/cards

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2024-01-04 00:30:41 +01:00
parent 595098368a
commit 47bc70f2c4
6 changed files with 174 additions and 7 deletions

View File

@@ -87,4 +87,14 @@ class AttachmentContext implements Context {
$this->requestContext->sendPlainRequest('GET', '/index.php/apps/deck/cards/' . $cardId . '/attachment/file:' . $attachmentId);
}
/**
* @When fetching the attachments for the card :cardReference
*/
public function fetchingTheAttachmentsForTheCard($cardReference) {
$cardId = $this->boardContext->getRememberedCard($cardReference)['id'] ?? null;
Assert::assertNotNull($cardId, 'Card needs to be available');
$this->requestContext->sendPlainRequest('GET', '/index.php/apps/deck/cards/' . $cardId . '/attachments');
}
}

View File

@@ -204,7 +204,9 @@ class BoardContext implements Context {
['description' => $description]
));
$this->requestContext->getResponse()->getBody()->seek(0);
$this->card = json_decode((string)$this->getResponse()->getBody(), true);
if ($this->requestContext->getResponse()->getStatusCode() === 200) {
$this->card = json_decode((string)$this->getResponse()->getBody(), true);
}
}
/**
@@ -216,7 +218,9 @@ class BoardContext implements Context {
[$attribute => $value]
));
$this->requestContext->getResponse()->getBody()->seek(0);
$this->card = json_decode((string)$this->getResponse()->getBody(), true);
if ($this->requestContext->getResponse()->getStatusCode() === 200) {
$this->card = json_decode((string)$this->getResponse()->getBody(), true);
}
}
/**
@@ -227,7 +231,9 @@ class BoardContext implements Context {
$this->card
));
$this->requestContext->getResponse()->getBody()->seek(0);
$this->card = json_decode((string)$this->getResponse()->getBody(), true);
if ($this->requestContext->getResponse()->getStatusCode() === 200) {
$this->card = json_decode((string)$this->getResponse()->getBody(), true);
}
}
/**
@@ -282,4 +288,18 @@ class BoardContext implements Context {
public function getRememberedCard($arg1) {
return $this->storedCards[$arg1] ?? null;
}
/**
* @Given /^delete the card$/
*/
public function deleteTheCard() {
$this->requestContext->sendJSONrequest('DELETE', '/index.php/apps/deck/cards/' . $this->card['id']);
}
/**
* @Given /^delete the board/
*/
public function deleteTheBoard() {
$this->requestContext->sendJSONrequest('DELETE', '/index.php/apps/deck/boards/' . $this->board['id']);
}
}

View File

@@ -11,6 +11,8 @@ class CommentContext implements Context {
/** @var BoardContext */
protected $boardContext;
private $lastComment = null;
/** @BeforeScenario */
public function gatherContexts(BeforeScenarioScope $scope) {
$environment = $scope->getEnvironment();
@@ -27,5 +29,34 @@ class CommentContext implements Context {
'message' => $content,
'parentId' => null
]);
$this->lastComment = $this->requestContext->getResponseBodyFromJson()['ocs']['data'] ?? null;
}
/**
* @Given /^get the comments on the card$/
*/
public function getCommentsOnTheCard() {
$card = $this->boardContext->getLastUsedCard();
$this->requestContext->sendOCSRequest('GET', '/apps/deck/api/v1.0/cards/' . $card['id'] . '/comments');
}
/**
* @When /^update a comment with content "([^"]*)" on the card$/
*/
public function updateACommentWithContentOnTheCard($content) {
$card = $this->boardContext->getLastUsedCard();
$this->requestContext->sendOCSRequest('PUT', '/apps/deck/api/v1.0/cards/' . $card['id'] . '/comments/'. $this->lastComment['id'], [
'message' => $content,
'parentId' => null
]);
}
/**
* @When /^delete the comment on the card$/
*/
public function deleteTheCommentOnTheCard() {
$card = $this->boardContext->getLastUsedCard();
$this->requestContext->sendOCSRequest('DELETE', '/apps/deck/api/v1.0/cards/' . $card['id'] . '/comments/'. $this->lastComment['id']);
}
}

View File

@@ -10,15 +10,15 @@ class ServerContext implements Context {
WebDav::__construct as private __tConstruct;
}
private string $rawBaseUrl;
private string $mappedUserId;
private array $lastInsertIds = [];
public function __construct($baseUrl) {
$this->rawBaseUrl = $baseUrl;
$this->__tConstruct($baseUrl . '/index.php/ocs/', ['admin', 'admin'], '123456');
}
/** @var string */
private $mappedUserId;
private $lastInsertIds = [];
/**
* @BeforeSuite