Testing table list checkbox click

What I am trying to do: I'm trying to add Pest test for Checkbox click on the ListRecords component. What I did: I tried these methods to execute checkbox click like beaviour:
livewire(ListOperators::class)->callTableColumnAction('user.is_active', $operator->id);
livewire(ListOperators::class)->callTableColumnAction('user.is_active', $operator->id);
livewire(ListOperators::class)->call('updateTableColumnState', ['user.is_active', $operator->id, true]);
livewire(ListOperators::class)->call('updateTableColumnState', ['user.is_active', $operator->id, true]);
My issue/the error: Nothing happens, test is not passing as I'm checking if user.is_active boolean value is changed in the db. Code:
public function table(Table $table): Table
{
return $table
->columns([
CheckboxColumn::make('user.is_active')
->tooltip(fn (Operator $record): string => $record->user->is_active ? 'Włączone' : 'Wyłączone')
->label('Status konta'),
]);
}
public function table(Table $table): Table
{
return $table
->columns([
CheckboxColumn::make('user.is_active')
->tooltip(fn (Operator $record): string => $record->user->is_active ? 'Włączone' : 'Wyłączone')
->label('Status konta'),
]);
}
test('it_allows_to_change_user_is_active_status_from_operator_list', function () {
$operator = Operator::factory()->create();

assertTrue($operator->user->is_active);

livewire(ListOperators::class)
->call('updateTableColumnState', ['user.is_active', $operator->id, false]);

livewire(ListOperators::class)
->callTableColumnAction('user.is_active', $operator->id);

assertFalse($operator->fresh()->user->fresh()->is_active); // not passing here
});
test('it_allows_to_change_user_is_active_status_from_operator_list', function () {
$operator = Operator::factory()->create();

assertTrue($operator->user->is_active);

livewire(ListOperators::class)
->call('updateTableColumnState', ['user.is_active', $operator->id, false]);

livewire(ListOperators::class)
->callTableColumnAction('user.is_active', $operator->id);

assertFalse($operator->fresh()->user->fresh()->is_active); // not passing here
});
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?