How to test that field hidden in infolist?

Test:
it('not shows empty description', function () {
    $project = Project::factory()->create(['description' => null]);

    livewire(ViewProject::class, [
        'record' => $project->getRouteKey(),
    ])
        ->assertFormFieldIsHidden('description');
});

Resource:
public static function infolist(Infolist $infolist): Infolist
    {
        return $infolist->schema([
            Infolists\Components\Section::make()->schema([
                Infolists\Components\TextEntry::make('name'),
                Infolists\Components\TextEntry::make('description')
                    ->label(false)
                    ->hidden(fn($record) => !$record->description)
                    ->markdown()
                    ->columnSpanFull(),
            ])
        ]);
    }

Error:
Failed asserting that a field with the name [description] is hidden on the form named [form] on the [App\Filament\Resources\ProjectResource\Pages\ViewProject] component.
Was this page helpful?