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
alexanderkroneisOP13mo ago
The test should cover a functionality from the app panel.
LeandroFerreira
LeandroFerreira13mo ago
try this before Livewire::test
Filament::setCurrentPanel('your_panel_id');
Filament::setCurrentPanel('your_panel_id');
alexanderkroneis
alexanderkroneisOP13mo ago
It doesn't take strings, just Panel|null :/
Solution
LeandroFerreira
LeandroFerreira13mo ago
sorry
$panel = Filament::getPanel('panel_id');
Filament::setCurrentPanel($panel);
$panel = Filament::getPanel('panel_id');
Filament::setCurrentPanel($panel);
alexanderkroneis
alexanderkroneisOP13mo ago
alexanderkroneis
alexanderkroneisOP13mo ago
Thanks!
Want results from more Discord servers?
Add your server