© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
12 replies
Mikazor

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');
});
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(),
            ])
        ]);
    }
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.
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.
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Field is hidden test - Pest
FilamentFFilament / ❓┊help
11mo ago
How to test Infolist Action?
FilamentFFilament / ❓┊help
2y ago
How to make secure hidden field?
FilamentFFilament / ❓┊help
2y ago
Test visible elements in Infolist
FilamentFFilament / ❓┊help
3y ago