Satal
Satal
FFilament
Created by Satal on 7/9/2024 in #❓┊help
Remove Manage Subscription from tenant menu
No description
11 replies
FFilament
Created by Satal on 6/27/2024 in #❓┊help
getMaxContentWidth not making RegisterTenant full width
No description
5 replies
FFilament
Created by Satal on 6/13/2024 in #❓┊help
Testing Header Action
I have the following in my EditTenantProfile
protected function getHeaderActions(): array
{
return [
Actions\Action::make('Delete Website')
->name('delete')
->icon('heroicon-m-x-mark')
->color('danger')
->requiresConfirmation()
->action(function () {
$tenant = tenant(); // these two lines are wrong but I'm writing the test
$tenant->delete(); // before I fix it.

Notifications\Notification::make()
->danger()
->title('Website deleted')
->body('The website has been deleted.')
->send();
}),
];
}
protected function getHeaderActions(): array
{
return [
Actions\Action::make('Delete Website')
->name('delete')
->icon('heroicon-m-x-mark')
->color('danger')
->requiresConfirmation()
->action(function () {
$tenant = tenant(); // these two lines are wrong but I'm writing the test
$tenant->delete(); // before I fix it.

Notifications\Notification::make()
->danger()
->title('Website deleted')
->body('The website has been deleted.')
->send();
}),
];
}
I'm trying to write a test and have got this far, however it doesn't work.
public function test_can_delete_website(): void
{
$tenant = $this->getTenant();
$this->visitPage($tenant);

Livewire::test(EditTeamProfile::class, ['tenant' => $tenant])
->assertSee('Delete Website')
->call('delete') // Adjust the method name if different in your code
->assertEmitted('confirming-action')
->call('confirmAction')
->assertEmitted('actionFinished', function ($payload) {
return $payload['title'] === 'Website deleted' &&
$payload['body'] === 'The website has been deleted.' &&
$payload['danger'] === true;
});

// Confirm tenant is deleted
$this->assertDatabaseMissing('tenants', [
'id' => $tenant->id,
]);
}
public function test_can_delete_website(): void
{
$tenant = $this->getTenant();
$this->visitPage($tenant);

Livewire::test(EditTeamProfile::class, ['tenant' => $tenant])
->assertSee('Delete Website')
->call('delete') // Adjust the method name if different in your code
->assertEmitted('confirming-action')
->call('confirmAction')
->assertEmitted('actionFinished', function ($payload) {
return $payload['title'] === 'Website deleted' &&
$payload['body'] === 'The website has been deleted.' &&
$payload['danger'] === true;
});

// Confirm tenant is deleted
$this->assertDatabaseMissing('tenants', [
'id' => $tenant->id,
]);
}
Does anyone have any good examples of tests for HeaderActions, they would be willing to share?
4 replies
FFilament
Created by Satal on 6/5/2024 in #❓┊help
Numeric but can be blank
No description
7 replies