Oussama
Oussama
FFilament
Created by Oussama on 8/28/2023 in #❓┊help
Refreshing table records after a page action
Currently using this implementation, which works technically but the notification animation isn't smooth, probably due to some re-rendering of the whole ManagesPodcastEpisodes::class, is there a way to only refresh records and not the whole thing?
// ManagesPodcastEpisodes::class
protected $listeners = [
'cache-cleared' => '$refresh',
];

protected function getHeaderActions(): array
{
return [
Action::make('forceRefresh')
->label('Force Refresh')
->action(function (): void {
Cache::forget(PodcastEpisode::CACHE_KEY);
// Sushi will handle the rest

Notification::make()
->success()
->title('Podcast episodes refreshed.')
->send();

$this->dispatch('cache-cleared');
}),
];
}
// ManagesPodcastEpisodes::class
protected $listeners = [
'cache-cleared' => '$refresh',
];

protected function getHeaderActions(): array
{
return [
Action::make('forceRefresh')
->label('Force Refresh')
->action(function (): void {
Cache::forget(PodcastEpisode::CACHE_KEY);
// Sushi will handle the rest

Notification::make()
->success()
->title('Podcast episodes refreshed.')
->send();

$this->dispatch('cache-cleared');
}),
];
}
3 replies
FFilament
Created by Oussama on 3/15/2023 in #❓┊help
Testing Creating a model via modal and File Upload
I'm trying to add tests that deal with creating/editing users /w avatars. Most testing examples in the docs related to having CreateRecord and EditRecord pages, not through modal actions.
it('can create a user', function () {
livewire(UserResource\Pages\ManageUsers::class)
->callPageAction('create', [
'name' => 'Saul Goodman',
'email' => '[email protected]',
'password' => 'some-password',
'avatar' => 'any.string.goes.here',
])
->assertHasNoPageActionErrors();
});
it('can create a user', function () {
livewire(UserResource\Pages\ManageUsers::class)
->callPageAction('create', [
'name' => 'Saul Goodman',
'email' => '[email protected]',
'password' => 'some-password',
'avatar' => 'any.string.goes.here',
])
->assertHasNoPageActionErrors();
});
This successfully creates a record and all, but I don't see a way of testing file uploads or that a field is hidden or not when creating vs editing. TL;DR: What's the proper way of testing creating or editing records when using modal actions, especially when it contains a file upload Any guidance is appreciated 🙏
3 replies