Testing: How to call a table action within a relation manager?

Hi, I have this Action within my CountriesRelationManager:
// CountriesRelationManager.php

public function table(Table $table): Table
{
return $table
// ...
->actions([
// ...
Action::make('moveUp')
->action(function (Action $action) {
$action->getRecord()->moveOrderUp();
}),
]);
// ...
}
// CountriesRelationManager.php

public function table(Table $table): Table
{
return $table
// ...
->actions([
// ...
Action::make('moveUp')
->action(function (Action $action) {
$action->getRecord()->moveOrderUp();
}),
]);
// ...
}
I'm looking to write a test for this custom action:
it('allows moves sort order up on assicated children', function () {
$continent = Continent::factory()
->hasCountries(2)
->create();

livewire(CountriesRelationManager::class, [
'pageClass' => EditContinent::class,
'ownerRecord' => $continent,
])
->callTableColumnAction('moveUp', $continent->countries->last()->id);

expect($continent->countries->first()->fresh()->sort_order)->toBe(2);
expect($continent->countries->last()->fresh()->sort_order)->toBe(1);
});
it('allows moves sort order up on assicated children', function () {
$continent = Continent::factory()
->hasCountries(2)
->create();

livewire(CountriesRelationManager::class, [
'pageClass' => EditContinent::class,
'ownerRecord' => $continent,
])
->callTableColumnAction('moveUp', $continent->countries->last()->id);

expect($continent->countries->first()->fresh()->sort_order)->toBe(2);
expect($continent->countries->last()->fresh()->sort_order)->toBe(1);
});
However, I'm getting the error:
Failed asserting that a table column with name [moveUp] exists on the [App\Filament\Resources\ContinentResource\RelationManagers\CountriesRelationManager] component.
Failed asserting that null is an instance of class Filament\Tables\Columns\Column.
Failed asserting that a table column with name [moveUp] exists on the [App\Filament\Resources\ContinentResource\RelationManagers\CountriesRelationManager] component.
Failed asserting that null is an instance of class Filament\Tables\Columns\Column.
Any ideas here on how to call moveUp ? Much appreciated!
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server