From 1c3eb2edff6dd526eee6f3f3744df59cf609ad6b Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Tue, 10 Mar 2026 00:54:32 +0100 Subject: [PATCH 1/2] fix(import): done state is not kept on importing a board Fix https://github.com/nextcloud/deck/issues/7536 Signed-off-by: Anna Larch --- .../Importer/Systems/DeckJsonService.php | 1 + tests/data/deck.json | 1 + tests/integration/import/ImportExportTest.php | 1 + .../Importer/Systems/DeckJsonServiceTest.php | 70 ++++++++++++++----- 4 files changed, 57 insertions(+), 16 deletions(-) diff --git a/lib/Service/Importer/Systems/DeckJsonService.php b/lib/Service/Importer/Systems/DeckJsonService.php index e569cd2e7e..8f74648d36 100644 --- a/lib/Service/Importer/Systems/DeckJsonService.php +++ b/lib/Service/Importer/Systems/DeckJsonService.php @@ -211,6 +211,7 @@ public function getCards(): array { $boardOwner = $this->getBoard()->getOwner(); $card->setOwner($this->mapOwner(is_string($boardOwner) ? $boardOwner : $boardOwner->getUID())); $card->setDuedate($cardSource->duedate); + $card->setDone($cardSource->done ?? null); $cards[$cardSource->id] = $card; } return $cards; diff --git a/tests/data/deck.json b/tests/data/deck.json index 6b00ce57a6..bd680ad650 100644 --- a/tests/data/deck.json +++ b/tests/data/deck.json @@ -100,6 +100,7 @@ }, "order": 999, "archived": false, + "done": "2023-07-18T10:00:00+00:00", "duedate": "2050-07-24T22:00:00+00:00", "deletedAt": 0, "commentsUnread": 0, diff --git a/tests/integration/import/ImportExportTest.php b/tests/integration/import/ImportExportTest.php index 436ec72125..83dca3b0ff 100644 --- a/tests/integration/import/ImportExportTest.php +++ b/tests/integration/import/ImportExportTest.php @@ -328,6 +328,7 @@ public function assertDatabase(string $owner = 'admin') { 'lastModified' => 1689667779, 'createdAt' => 1689667569, 'owner' => $owner, + 'done' => new \DateTime('2023-07-18T10:00:00+00:00'), 'duedate' => new \DateTime('2050-07-24T22:00:00.000000+0000'), 'order' => 999, 'stackId' => $stacks[0]->getId(), diff --git a/tests/unit/Service/Importer/Systems/DeckJsonServiceTest.php b/tests/unit/Service/Importer/Systems/DeckJsonServiceTest.php index a2c6d7f6aa..b4947d8558 100644 --- a/tests/unit/Service/Importer/Systems/DeckJsonServiceTest.php +++ b/tests/unit/Service/Importer/Systems/DeckJsonServiceTest.php @@ -24,8 +24,6 @@ namespace OCA\Deck\Service\Importer\Systems; use OCA\Deck\Service\Importer\BoardImportService; -use OCP\IL10N; -use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserManager; use OCP\Server; @@ -36,20 +34,12 @@ */ class DeckJsonServiceTest extends \Test\TestCase { private DeckJsonService $service; - /** @var IURLGenerator|MockObject */ - private $urlGenerator; /** @var IUserManager|MockObject */ private $userManager; - /** @var IL10N */ - private $l10n; public function setUp(): void { $this->userManager = $this->createMock(IUserManager::class); - $this->urlGenerator = $this->createMock(IURLGenerator::class); - $this->l10n = $this->createMock(IL10N::class); $this->service = new DeckJsonService( $this->userManager, - $this->urlGenerator, - $this->l10n ); } @@ -61,6 +51,59 @@ public function testGetBoardWithNoName() { } public function testGetBoardWithSuccess() { + $importService = $this->setUpImportService(); + + $boards = $this->service->getBoards(); + $importService->setData($boards[0]); + $actual = $this->service->getBoard(); + $this->assertEquals('My test board', $actual->getTitle()); + $this->assertEquals('admin', $actual->getOwner()); + $this->assertEquals('e0ed31', $actual->getColor()); + } + + public function testGetCards() { + $importService = $this->setUpImportService(); + + $boards = $this->service->getBoards(); + $importService->setData($boards[0]); + + $importService->getBoard()->setId(1); + + $this->service->getLabels(); + + $stacks = $this->service->getStacks(); + $stackId = 1; + foreach ($stacks as $code => $stack) { + $stack->setId($stackId++); + $this->service->updateStack($code, $stack); + } + + $cards = $this->service->getCards(); + + $this->assertCount(6, $cards); + + // Card 114 (title "1") has a done value set in the fixture + $card114 = $cards[114]; + $this->assertEquals('1', $card114->getTitle()); + $this->assertInstanceOf(\DateTime::class, $card114->getDone()); + $this->assertEquals('2023-07-18T10:00:00+00:00', $card114->getDone()->format(\DateTime::ATOM)); + $this->assertEquals('2050-07-24T22:00:00+00:00', $card114->getDuedate()->format(\DateTime::ATOM)); + $this->assertFalse($card114->getArchived()); + $this->assertEquals('admin', $card114->getOwner()); + + // Card 115 (title "2") has no done value in the fixture + $card115 = $cards[115]; + $this->assertEquals('2', $card115->getTitle()); + $this->assertNull($card115->getDone()); + + // Card 119 (title "6") — from stack B, no done value + $card119 = $cards[119]; + $this->assertEquals('6', $card119->getTitle()); + $this->assertNull($card119->getDone()); + $this->assertEquals('# Test description' . "\n\n" . 'Hello world', $card119->getDescription()); + } + + private function setUpImportService(): BoardImportService { $importService = Server::get(BoardImportService::class); $data = json_decode(file_get_contents(__DIR__ . '/../../../../data/deck.json')); @@ -77,11 +120,6 @@ public function testGetBoardWithSuccess() { $this->service->setImportService($importService); - $boards = $this->service->getBoards(); - $importService->setData($boards[0]); - $actual = $this->service->getBoard(); - $this->assertEquals('My test board', $actual->getTitle()); - $this->assertEquals('admin', $actual->getOwner()); - $this->assertEquals('e0ed31', $actual->getColor()); + return $importService; } } From 40e36d93be470a4b3abb2e8c2de9b5a7845783c8 Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Tue, 10 Mar 2026 01:02:20 +0100 Subject: [PATCH 2/2] chore: increase base query counter Signed-off-by: Anna Larch --- tests/integration/base-query-count.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/base-query-count.txt b/tests/integration/base-query-count.txt index 93e564594a..a0de8ecd9f 100644 --- a/tests/integration/base-query-count.txt +++ b/tests/integration/base-query-count.txt @@ -1 +1 @@ -84323 +84627