Skip to content

Commit

Permalink
feat:[LAR-70]Add label in text input,remove space in files and add co…
Browse files Browse the repository at this point in the history
…unt table record after filter in discussion feature test
  • Loading branch information
Chri$ committed Oct 21, 2024
1 parent d32ce5b commit b553afc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
8 changes: 5 additions & 3 deletions app/Filament/Resources/DiscussionResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ public static function table(Table $table): Table
TextColumn::make('title')
->label('Titre')
->sortable(),
TextColumn::make('Vérrouillé')
TextColumn::make('locked')
->label(label: 'Vérrouillé')
->getStateUsing(fn ($record) => ($record->locked) ? 'OUI' : 'NON')
->colors([
'success' => 'OUI',
'danger' => 'NON',
])
->badge(),
TextColumn::make('Epinglé')
TextColumn::make('is_pinned')
->label(label: 'Epinglé')
->getStateUsing(fn ($record) => ($record->is_pinned) ? 'OUI' : 'NON')
->colors([
'success' => 'OUI',
Expand All @@ -51,7 +53,7 @@ public static function table(Table $table): Table
Filter::make('is_locked')->query(fn (Builder $query) => $query->where('locked', true))->label('Vérrouillé'),
])
->actions([
Tables\Actions\DeleteAction::make('delete'),
Tables\Actions\DeleteAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Expand Down
23 changes: 8 additions & 15 deletions tests/Feature/Filament/DiscussionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@
use App\Filament\Resources\DiscussionResource;
use App\Filament\Resources\DiscussionResource\Pages\ListDiscussions;
use App\Models\Discussion;
use Illuminate\Database\Eloquent\Factories\Sequence;
use Livewire\Livewire;

beforeEach(function (): void {
$this->user = $this->login();
$this->discussions = Discussion::factory()
->count(10)
->state(function () {
return [
'is_pinned' => rand(0, 1),
'locked' => rand(0, 1),
'created_at' => now(),
];
})
->state(new Sequence(
['is_pinned' => true, 'locked' => false],
['is_pinned' => false, 'locked' => true],
))
->create();
});

Expand All @@ -29,21 +27,16 @@
});

it('admin user can filter discussion by `is_pinned`', function (): void {

Livewire::test(ListDiscussions::class)
->assertCanSeeTableRecords($this->discussions)
->filterTable('is_pinned')
->assertCanSeeTableRecords($this->discussions->where('is_pinned', true))
->assertCanNotSeeTableRecords($this->discussions->where('is_pinned', false));
->assertCountTableRecords(5);
});

it('admin user can filter discussion by `locked`', function (): void {

Livewire::test(ListDiscussions::class)
->assertCanSeeTableRecords($this->discussions)
->filterTable('is_locked')
->assertCanSeeTableRecords($this->discussions->where('locked', true))
->assertCanNotSeeTableRecords($this->discussions->where('locked', false));
->assertCountTableRecords(5);
});

})->group(groups: 'discussions');
})->group('discussions');

0 comments on commit b553afc

Please sign in to comment.