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:
In my test I am doing something like this:
When I run the test I get the following Error message:
So I assume to set a value in the filter form I need to use something different then
Any tipps very appreciated!
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 );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....So I assume to set a value in the filter form I need to use something different then
->filterTable('hawb', 'XYZ') ?! How do I interact with the filterform of my tablecomponent in a test?Any tipps very appreciated!