© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
1 reply
ahinkle

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

Hi, I have this Action within my
CountriesRelationManager
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
moveUp
? Much appreciated!
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

Testing Table Header action in relation manager?
FilamentFFilament / ❓┊help
2y ago
Open relation manager on table action
FilamentFFilament / ❓┊help
11mo ago
Testing relation manager actions
FilamentFFilament / ❓┊help
12mo ago
Testing Filament Relation Manager
FilamentFFilament / ❓┊help
2y ago