Closed luanfreitasdev closed 2 months ago
Since the actions are not rendered with PHP but with JavaScript, it isn't easy to test the complete flow, but we can ensure that the data that is being expected in PowerGrid remains intact with some assertions.
Example:
Component
public function actions($row): array { return [ Button::add('view') ->icon('default-eye', [ 'class' => '!text-green-500', ]) ->slot('View') ->class('text-slate-500 flex gap-2 hover:text-slate-700 hover:bg-slate-100 font-bold p-1 px-2 rounded') ->dispatch('clickToEdit', ['dishId' => $row?->id, 'dishName' => $row?->name]), ]; }
Test file
livewire(DishesCollectionTable::class) ->call('setTestThemeClass', $params->theme) ->assertHasAction('view') ->assertActionContainsAttribute('view', 'class', 'flex gap-2 hover:text-slate-700') ->assertActionContainsAttribute('view', 'wire:click', 'clickToEdit', ['dishId' => 29, 'dishName' => 'Luan']) ->assertActionHasIcon('view', 'default-eye', '!text-green-500')
Since the actions are not rendered with PHP but with JavaScript, it isn't easy to test the complete flow, but we can ensure that the data that is being expected in PowerGrid remains intact with some assertions.
Example:
Component
Test file