F
Filamentβ€’11mo ago
neil.keena

Assert Table Action is Disabled

I have the following test that fails and I don't know why. Any one have an idea what I'm missing? Or is this a bug as it does not seem to be evaluating isDisabled() on the action
it('cannot delete program type in use', function () {
$record = ProgramType::factory()->has(\App\Models\Program::factory())->create();

expect($record->programs->count())->toBe(1);

livewire(ListProgramTypes::class)
->assertTableActionExists('delete')
->assertTableActionDisabled('delete', $record);
});
it('cannot delete program type in use', function () {
$record = ProgramType::factory()->has(\App\Models\Program::factory())->create();

expect($record->programs->count())->toBe(1);

livewire(ListProgramTypes::class)
->assertTableActionExists('delete')
->assertTableActionDisabled('delete', $record);
});
And the DeleteAction in the table is disabled using the following closure:
DeleteAction::make()
->iconButton()
->color('gray')
->disabled(fn ($record) => $record->programs_count > 0)
->tooltip('Delete')
->modalIconColor('danger')
->modalHeading(fn ($record) => "Delete program type: \"{$record->name}\"")
->modalSubmitAction(
fn ($action) => $action
->color('danger')
->label('Delete')
),
DeleteAction::make()
->iconButton()
->color('gray')
->disabled(fn ($record) => $record->programs_count > 0)
->tooltip('Delete')
->modalIconColor('danger')
->modalHeading(fn ($record) => "Delete program type: \"{$record->name}\"")
->modalSubmitAction(
fn ($action) => $action
->color('danger')
->label('Delete')
),
The programs_count attribute does exist and this works in the browser but the test failes.
TextColumn::make('programs_count')->label('Programs')->counts('programs')->alignEnd(),
TextColumn::make('programs_count')->label('Programs')->counts('programs')->alignEnd(),
Any help would be greatly appreciated πŸ™πŸΌ
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?