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(); }), ];}
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, ]);}