Test different panels

Hi, how can I test different panels e.g.
test('can create a user', function () {
$user = User::factory()->make();

Livewire::test(UserResource\Pages\CreateUser::class)
->fillForm([
'name' => $user->name,
'email' => $user->email,
])
->call('create')
->assertHasNoFormErrors();

$this->assertDatabaseHas(User::class, [
'name' => $user->name,
'email' => $user->email,
]);
});
test('can create a user', function () {
$user = User::factory()->make();

Livewire::test(UserResource\Pages\CreateUser::class)
->fillForm([
'name' => $user->name,
'email' => $user->email,
])
->call('create')
->assertHasNoFormErrors();

$this->assertDatabaseHas(User::class, [
'name' => $user->name,
'email' => $user->email,
]);
});
If I run php artisan test I get this error:
Route [filament.admin.resources.users.index] not defined. (View: /var/www/html/vendor/filament/filament/resources/views/components/page/index.blade.php) (View: /var/www/html/vendor/filament/filament/resources/views/components/page/index.blade.php) (View: /var/www/html/vendor/filament/filament/resources/views/components/page/index.blade.php)
Route [filament.admin.resources.users.index] not defined. (View: /var/www/html/vendor/filament/filament/resources/views/components/page/index.blade.php) (View: /var/www/html/vendor/filament/filament/resources/views/components/page/index.blade.php) (View: /var/www/html/vendor/filament/filament/resources/views/components/page/index.blade.php)
Solution:
sorry
$panel = Filament::getPanel('panel_id');
Filament::setCurrentPanel($panel);
$panel = Filament::getPanel('panel_id');
Filament::setCurrentPanel($panel);
...
Jump to solution
6 Replies
alexanderkroneis
alexanderkroneisOP14mo ago
The test should cover a functionality from the app panel.
LeandroFerreira
LeandroFerreira14mo ago
try this before Livewire::test
Filament::setCurrentPanel('your_panel_id');
Filament::setCurrentPanel('your_panel_id');
alexanderkroneis
alexanderkroneisOP14mo ago
It doesn't take strings, just Panel|null :/
Solution
LeandroFerreira
LeandroFerreira14mo ago
sorry
$panel = Filament::getPanel('panel_id');
Filament::setCurrentPanel($panel);
$panel = Filament::getPanel('panel_id');
Filament::setCurrentPanel($panel);
alexanderkroneis
alexanderkroneisOP14mo ago
alexanderkroneis
alexanderkroneisOP14mo ago
Thanks!
Want results from more Discord servers?
Add your server