F
Filament16mo ago
Čamap

Assert visibility of every field of Tab in resource form

Is there a way to assert that entire Tab with fields in form is visible/hidden? I've got a form with this schema
public static function form(Form $form): Form
{
return $form
->schema([
Tabs::make('tabs')->schema([
Tab::make(__('Internal services'))
->visible(true) // dummy condition
->schema(self::internalFields()),

Tab::make(__('External services'))
->visible(false) // dummy condition
->schema(self::externalFields()),

.....
public static function form(Form $form): Form
{
return $form
->schema([
Tabs::make('tabs')->schema([
Tab::make(__('Internal services'))
->visible(true) // dummy condition
->schema(self::internalFields()),

Tab::make(__('External services'))
->visible(false) // dummy condition
->schema(self::externalFields()),

.....
I want to assert that all fields in Internal services tab are visible and assert that all fields in External services tab are hidden. I'm currently asserting visibility of each field, which seems a bit excessive, since every tab has like 15 fields..
3 Replies
Patrick Boivin
Patrick Boivin16mo ago
Have you tried ->assertSee() with the field id or dusk attributes?
Čamap
ČamapOP16mo ago
You mean adding id to Tab?
Patrick Boivin
Patrick Boivin16mo ago
No, your form fields all have HTML id attributes already. You could use this with ->assertSee() in your tests. I think each tab also has an id already, maybe you can use that.
Want results from more Discord servers?
Add your server