Krishzzi
Krishzzi
FFilament
Created by Krishzzi on 5/17/2024 in #❓┊help
..need help on Form Wizard Pest Test With Each Step Form Validation
I have a custom page which extends
use Filament\Pages\Page;
use Filament\Pages\Page;
now in this page I use
use Filament\Pages\Concerns\InteractsWithFormActions;
use Filament\Pages\Concerns\InteractsWithFormActions;
as trait and use this page for form. in form schema I have wizard with 3 steps. How I can call wizard next and previous steps that I can test form validation with pest test. Example:-
livewire(ProfileSetup::class)
->fillForm([
'field_name' => 'field_value',
'second_field_name' => [
'child_field' => null,
'child_field' => 'some_value',
],
])
->call('') // here I want to call form wizard next and previous step action button
->assertHasNoFormErrors()
livewire(ProfileSetup::class)
->fillForm([
'field_name' => 'field_value',
'second_field_name' => [
'child_field' => null,
'child_field' => 'some_value',
],
])
->call('') // here I want to call form wizard next and previous step action button
->assertHasNoFormErrors()
In wizard I have step like this..
Wizard\Step::make('Information')
->columns(2)
->statePath('custom_data')
->model(fn () => $this->customModel ?? CustomModel::class)
->afterValidation(function () {
if (! $this->disableForm) {
$this->saveFirstStepInfo();
}
})
->schema($this->getFirstStepFormSchema()),
Wizard\Step::make('Information')
->columns(2)
->statePath('custom_data')
->model(fn () => $this->customModel ?? CustomModel::class)
->afterValidation(function () {
if (! $this->disableForm) {
$this->saveFirstStepInfo();
}
})
->schema($this->getFirstStepFormSchema()),
like this I have total three steps, how test wizard form with step by step form validation
1 replies
FFilament
Created by Krishzzi on 5/7/2024 in #❓┊help
get_class(): Argument #1 ($object) must be of type object, null given Filament::auth()
I have a common resource for multiple users (User model, Artist Model, Affiliate Model) etc. in the list page, in table query I have like this.. to only load logged in user specific records
public function table(Table $table): Table
{
return $table
->modifyQueryUsing(fn ($query) => $query->published()->forUserType(get_class(Filament::auth()->user()));
}
public function table(Table $table): Table
{
return $table
->modifyQueryUsing(fn ($query) => $query->published()->forUserType(get_class(Filament::auth()->user()));
}
here we basicaly call where user_type = current auth user class this works fine .. but in test , when I do
$this->get(HelpModuleResource::getUrl('index'))->assertSuccessful();
$this->get(HelpModuleResource::getUrl('index'))->assertSuccessful();
I also add beforeEach for my pest test
beforeEach(function () {
$this->actingAs(Artist::factory()->create(), 'artist');
$this->actingAs(User::factory()->create(), 'web');
// other users
});
beforeEach(function () {
$this->actingAs(Artist::factory()->create(), 'artist');
$this->actingAs(User::factory()->create(), 'web');
// other users
});
I try to do this too chain with actingAs()->startSession() but still same error I get this error : get_class(): Argument #1 ($object) must be of type object, null given why Filament::auth()->user() is null while user actingAs and how to fix this..
11 replies