FilamentF
Filamentβ€’9mo ago
D5300

Field is hidden test - Pest

Hi guys,

I have on my tenant create a form which I want to test. It has a depending field which I try to test if its visible or not. But using isVisible or isHidden, both return an error:

Failed asserting that a field with the name [company_name] is hidden on the form named [form] on the [App\Filament\Pages\Tenancy\RegisterWebsite] component.
Failed asserting that an array does not have the key 'company_name'.

My test looks like the following:

it('hides the company name field when you want to create a new company', function () {
            $user = newUser();
            $this->actingAs($user);
            $company = Company::factory(['owner_id' => $user])->create();
            Website::factory(['company_id' => $company])->create();

            $livewire = livewire(RegisterWebsite::class);

            $livewire->fillForm([
                'company_id' => Company::first()->id
            ]);

            $livewire->assertFormFieldIsHidden('company_name');
        });


The form will be in a seperate message as I dont have discord premium πŸ˜„
Was this page helpful?