Skip to content

Commit bf10dcb

Browse files
committed
feat: add test fixtures for BoardResourcePage and TestResource
1 parent 75aed19 commit bf10dcb

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Relaticle\Flowforge\Tests\Fixtures;
6+
7+
use Filament\Resources\Pages\Concerns\InteractsWithRecord;
8+
use Relaticle\Flowforge\Board;
9+
use Relaticle\Flowforge\BoardResourcePage;
10+
use Relaticle\Flowforge\Column;
11+
12+
/**
13+
* Test fixture for BoardResourcePage that uses InteractsWithRecord.
14+
* Replicates the GitHub issue #37 scenario where a project has many tasks.
15+
*/
16+
class TestBoardResourcePage extends BoardResourcePage
17+
{
18+
use InteractsWithRecord;
19+
20+
protected static string $resource = TestResource::class;
21+
22+
public function mount(int | string $record): void
23+
{
24+
$this->record = $this->resolveRecord($record);
25+
}
26+
27+
public function board(Board $board): Board
28+
{
29+
// Use $this->getRecord() to scope tasks to this project
30+
return $board
31+
->query($this->getRecord()->tasks()->getQuery())
32+
->recordTitleAttribute('title')
33+
->columnIdentifier('status')
34+
->positionIdentifier('order_position')
35+
->columns([
36+
Column::make('todo')->label('To Do')->color('gray'),
37+
Column::make('in_progress')->label('In Progress')->color('blue'),
38+
Column::make('completed')->label('Completed')->color('green'),
39+
]);
40+
}
41+
}

tests/Fixtures/TestResource.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Relaticle\Flowforge\Tests\Fixtures;
6+
7+
use Filament\Resources\Resource;
8+
9+
/**
10+
* Minimal test resource for TestBoardResourcePage.
11+
*/
12+
class TestResource extends Resource
13+
{
14+
protected static ?string $model = Project::class;
15+
16+
protected static ?string $slug = 'test-projects';
17+
18+
public static function getPages(): array
19+
{
20+
return [
21+
'board' => TestBoardResourcePage::route('/{record}/board'),
22+
];
23+
}
24+
}

0 commit comments

Comments
 (0)