FilamentF
Filament10mo ago
Laurens

Testing relation manager actions

I am trying to test the actions of relation managers to get 100% code coverage across an internal project we have. However, the furthest I can get are exception that the create actions is not being rendered/present on the livewire component.

I am seeing the create action while logged into the panel.

This is a trimmed down WIP of an example test I have with some specific business logic from the app trimmed out.

it('can create project assets', function () {
    $this->actingAs($user = $this->createTeamUser()->fresh());

    // Create dummy owner record
    $ownerRecord = Project::factory()->create();

    // Prepare dummy data
    $data = Asset::factory()->make();

    livewire(ProjectResource\RelationManagers\AssetsRelationManager::class, [
        'pageClass' => ProjectResource\Pages\EditProject::class,
        'ownerRecord' => $ownerRecord,
    ])
        ->callAction(CreateAction::class, $data->only(['name', 'url']))
        ->assertSuccessful();

    // Verify the record exists
    $this->assertDatabaseHas(Asset::class, $data->only(['name', 'url']));
})->skip('cannot assert on relation manager');


This is happening for me in an Laravel 11 project with Filament v3.3.x.

Is there any way to test actions for relation managers?

Thanks in advance!
Was this page helpful?