From 586e218cdb00f7e4cc1ec99f70b4cd9f27ef138a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 9 Jan 2026 03:18:02 +0000 Subject: [PATCH 1/4] Initial plan From e8702b9cc89b064d1c60ab49569d6fd12aac90ef Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 9 Jan 2026 03:20:53 +0000 Subject: [PATCH 2/4] Fix ReportBlocksTable imports, actions, GridSnapperService, test mock, and CSS syntax Co-authored-by: nielsdrost7 <47660417+nielsdrost7@users.noreply.github.com> --- .../ReportBlocks/Tables/ReportBlocksTable.php | 10 +++++----- Modules/Core/Services/GridSnapperService.php | 2 +- Modules/Core/Tests/Unit/ReportTemplateServiceTest.php | 2 +- resources/css/filament/company/invoiceplane.css | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Modules/Core/Filament/Admin/Resources/ReportBlocks/Tables/ReportBlocksTable.php b/Modules/Core/Filament/Admin/Resources/ReportBlocks/Tables/ReportBlocksTable.php index 8d4fb1ecf..18d8dca15 100644 --- a/Modules/Core/Filament/Admin/Resources/ReportBlocks/Tables/ReportBlocksTable.php +++ b/Modules/Core/Filament/Admin/Resources/ReportBlocks/Tables/ReportBlocksTable.php @@ -2,9 +2,9 @@ namespace Modules\Core\Filament\Admin\Resources\ReportBlocks\Tables; -use Filament\Actions\ActionGroup; -use Filament\Actions\DeleteAction; -use Filament\Actions\EditAction; +use Filament\Tables\Actions\ActionGroup; +use Filament\Tables\Actions\DeleteAction; +use Filament\Tables\Actions\EditAction; use Filament\Tables\Columns\IconColumn; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Table; @@ -36,11 +36,11 @@ public static function configure(Table $table): Table ->boolean() ->sortable(), ]) - ->recordActions([ + ->actions([ ActionGroup::make([ EditAction::make(), DeleteAction::make('delete') - ->action(function (ReportBlock $record, array $data) { + ->action(function (ReportBlock $record) { app(ReportBlockService::class)->deleteReportBlock($record); }), ]), diff --git a/Modules/Core/Services/GridSnapperService.php b/Modules/Core/Services/GridSnapperService.php index 694715bea..8012fb12d 100644 --- a/Modules/Core/Services/GridSnapperService.php +++ b/Modules/Core/Services/GridSnapperService.php @@ -26,7 +26,7 @@ public function snap(GridPositionDTO $position): GridPositionDTO { $x = max(0, min($position->getX(), $this->gridSize - 1)); $y = max(0, $position->getY()); - $width = max(1, min($position->getWidth(), $this->gridSize - $position->getX())); + $width = max(1, min($position->getWidth(), $this->gridSize - $x)); $height = max(1, $position->getHeight()); return GridPositionDTO::create($x, $y, $width, $height); diff --git a/Modules/Core/Tests/Unit/ReportTemplateServiceTest.php b/Modules/Core/Tests/Unit/ReportTemplateServiceTest.php index b7a44acf8..4739735fe 100644 --- a/Modules/Core/Tests/Unit/ReportTemplateServiceTest.php +++ b/Modules/Core/Tests/Unit/ReportTemplateServiceTest.php @@ -228,7 +228,7 @@ public function it_loads_blocks(): void $template->slug = 'test-template'; $this->fileRepository->expects($this->once()) - ->method('load') + ->method('get') ->with(1, 'test-template') ->willReturn([ [ diff --git a/resources/css/filament/company/invoiceplane.css b/resources/css/filament/company/invoiceplane.css index 96b82d17a..cd97219e5 100644 --- a/resources/css/filament/company/invoiceplane.css +++ b/resources/css/filament/company/invoiceplane.css @@ -58,7 +58,7 @@ .fi-sidebar-item.fi-active { @apply text-white; - @apply !bg-primary-700; + @apply bg-primary-700!; @apply rounded-lg; } From eaa747f72ea8a1dd94a5d0336718293981203152 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 9 Jan 2026 03:46:52 +0000 Subject: [PATCH 3/4] Refactor tests to use Storage::fake() instead of mocking repository Co-authored-by: nielsdrost7 <47660417+nielsdrost7@users.noreply.github.com> --- .../Tests/Unit/ReportTemplateServiceTest.php | 47 ++++++++++++------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/Modules/Core/Tests/Unit/ReportTemplateServiceTest.php b/Modules/Core/Tests/Unit/ReportTemplateServiceTest.php index 4739735fe..f07a0cc13 100644 --- a/Modules/Core/Tests/Unit/ReportTemplateServiceTest.php +++ b/Modules/Core/Tests/Unit/ReportTemplateServiceTest.php @@ -2,6 +2,7 @@ namespace Modules\Core\Tests\Unit; +use Illuminate\Support\Facades\Storage; use InvalidArgumentException; use Modules\Core\DTOs\BlockDTO; use Modules\Core\DTOs\GridPositionDTO; @@ -26,7 +27,9 @@ protected function setUp(): void { parent::setUp(); - $this->fileRepository = $this->createMock(ReportTemplateFileRepository::class); + Storage::fake('report_templates'); + + $this->fileRepository = new ReportTemplateFileRepository(); $this->gridSnapper = new GridSnapperService(12); $this->service = new ReportTemplateService($this->fileRepository, $this->gridSnapper); } @@ -200,11 +203,8 @@ public function it_persists_blocks(): void $template->slug = 'test-template'; $position = new GridPositionDTO(); - - /* act */ $position->setX(0)->setY(0)->setWidth(6)->setHeight(4); - /* assert */ $block = new BlockDTO(); $block->setId('block_1') ->setType('company_header') @@ -212,10 +212,19 @@ public function it_persists_blocks(): void ->setConfig([]) ->setIsCloneable(true) ->setIsCloned(false); - $this->fileRepository->expects($this->once()) - ->method('save') - ->with(1, 'test-template', $this->isType('array')); + + /* act */ $this->service->persistBlocks($template, [$block]); + + /* assert */ + Storage::disk('report_templates')->assertExists('1/test-template.json'); + $content = Storage::disk('report_templates')->get('1/test-template.json'); + $data = json_decode($content, true); + + $this->assertIsArray($data); + $this->assertCount(1, $data); + $this->assertEquals('block_1', $data[0]['id']); + $this->assertEquals('company_header', $data[0]['type']); } #[Test] @@ -227,17 +236,19 @@ public function it_loads_blocks(): void $template->company_id = 1; $template->slug = 'test-template'; - $this->fileRepository->expects($this->once()) - ->method('get') - ->with(1, 'test-template') - ->willReturn([ - [ - 'id' => 'block_1', - 'type' => 'company_header', - 'position' => ['x' => 0, 'y' => 0, 'width' => 6, 'height' => 4], - 'config' => [], - ], - ]); + $fileData = [ + [ + 'id' => 'block_1', + 'type' => 'company_header', + 'position' => ['x' => 0, 'y' => 0, 'width' => 6, 'height' => 4], + 'config' => [], + ], + ]; + + Storage::disk('report_templates')->put( + '1/test-template.json', + json_encode($fileData, JSON_PRETTY_PRINT) + ); /* act */ $blocks = $this->service->loadBlocks($template); From 50d2b8536b8a724155a4f59692abc9c55697cf30 Mon Sep 17 00:00:00 2001 From: Niels Drost <47660417+nielsdrost7@users.noreply.github.com> Date: Fri, 9 Jan 2026 05:05:14 +0100 Subject: [PATCH 4/4] Change actions to recordActions in ReportBlocksTable --- .../Admin/Resources/ReportBlocks/Tables/ReportBlocksTable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Core/Filament/Admin/Resources/ReportBlocks/Tables/ReportBlocksTable.php b/Modules/Core/Filament/Admin/Resources/ReportBlocks/Tables/ReportBlocksTable.php index 18d8dca15..2ef400cc0 100644 --- a/Modules/Core/Filament/Admin/Resources/ReportBlocks/Tables/ReportBlocksTable.php +++ b/Modules/Core/Filament/Admin/Resources/ReportBlocks/Tables/ReportBlocksTable.php @@ -36,7 +36,7 @@ public static function configure(Table $table): Table ->boolean() ->sortable(), ]) - ->actions([ + ->recordActions([ ActionGroup::make([ EditAction::make(), DeleteAction::make('delete')