© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
7 replies
low-res (Paul)

How to test table with filter form

Hi Experts. I have a table component with a pretty complex filterform. Everything is running well. Now I want to write some tests for this tablecomponent to make sure all my filters are working correctly. The relevant parts of the tabledefinition in the resource looks like this:
   return $table
            ->columns( ... )
            ->filters([
                Filter::make('Filter')->columnSpan(12)->form([
                    Grid::make(['default' => 12])->schema([
                        Section::make('fixed_section')
                            ->columnSpan(12)
                            ->schema([
                                Grid::make(5)->schema([
                                    TextInput::make('hawb'),
                                    
                           ...
                        
                    ])
                ])
                    ->query(function (Builder $query, array $data): Builder {
                        ...
                    })
            ])
            ->filtersLayout(Layout::AboveContent)
            ->actions([])
            ->bulkActions([]);
   return $table
            ->columns( ... )
            ->filters([
                Filter::make('Filter')->columnSpan(12)->form([
                    Grid::make(['default' => 12])->schema([
                        Section::make('fixed_section')
                            ->columnSpan(12)
                            ->schema([
                                Grid::make(5)->schema([
                                    TextInput::make('hawb'),
                                    
                           ...
                        
                    ])
                ])
                    ->query(function (Builder $query, array $data): Builder {
                        ...
                    })
            ])
            ->filtersLayout(Layout::AboveContent)
            ->actions([])
            ->bulkActions([]);


In my test I am doing something like this:

Livewire::test(ListShipments::class)
            ->assertCanSeeTableRecords( $allShipments )
            ->filterTable('hawb', 'XYZ')
            ->assertCanSeeTableRecords( $specificShipments );
Livewire::test(ListShipments::class)
            ->assertCanSeeTableRecords( $allShipments )
            ->filterTable('hawb', 'XYZ')
            ->assertCanSeeTableRecords( $specificShipments );


When I run the test I get the following Error message:

Failed asserting that a table filter with name [hawb] exists on the [App\Filament\Resources\ShipmentResource....
Failed asserting that a table filter with name [hawb] exists on the [App\Filament\Resources\ShipmentResource....


So I assume to set a value in the filter form I need to use something different then
 ->filterTable('hawb', 'XYZ')
 ->filterTable('hawb', 'XYZ')
?! How do I interact with the filterform of my tablecomponent in a test?
Any tipps very appreciated!
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

How to permanently filter table
FilamentFFilament / ❓┊help
3y ago
Make it Inline Form Filter Table
FilamentFFilament / ❓┊help
3y ago
Filter with Custom Form
FilamentFFilament / ❓┊help
3y ago