F
Filament6mo ago
Ron

Testing call wizard next step fails

I am unable to get my Pest test function to actually call the form wizard next step.
CreateUserTest.php
use function Pest\Livewire\livewire;

it('can validate creating a user', function () {
livewire(UserResource\Pages\CreateUser::class)
->fillForm([])
->callFormComponentAction(component: 'create-user', name: 'next')
->assertHasFormErrors(['name' => 'The name field is required.']);
});
use function Pest\Livewire\livewire;

it('can validate creating a user', function () {
livewire(UserResource\Pages\CreateUser::class)
->fillForm([])
->callFormComponentAction(component: 'create-user', name: 'next')
->assertHasFormErrors(['name' => 'The name field is required.']);
});
This test fails with "Component has no errors" but the name field is required. Following the test source code and injecting "ray()" debug calls, it appears the next step action is not called. CreateUser.php
use CreateRecord\Concerns\HasWizard;
public function form(Form $form): Form
{
return parent::form($form)
->schema([
Wizard::make($this->getSteps())
->key('data.create-user')
...
]);
}
protected function getSteps(): array
{
return [
Step::make('Name')
->schema([
TextInput::make('name')->required(),
]),
Step::make('Email')
->schema([
TextInput::make('email')->email()->required(),
]),
];
}
use CreateRecord\Concerns\HasWizard;
public function form(Form $form): Form
{
return parent::form($form)
->schema([
Wizard::make($this->getSteps())
->key('data.create-user')
...
]);
}
protected function getSteps(): array
{
return [
Step::make('Name')
->schema([
TextInput::make('name')->required(),
]),
Step::make('Email')
->schema([
TextInput::make('email')->email()->required(),
]),
];
}
I referenced the following this link https://filamentphp.com/docs/3.x/panels/resources/creating-records#using-a-wizard in the docs. Does anyone know the correct way to test the next step action in a form wizard?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server