Tricks

Test an editable column

Apr 17, 2023
Jyrki De Neve
Table builder

If you have a TextInputColumn or any other Column that implements the Editable contract. And added a updateUsing, you can test this functionality with following code:

it('can edit the title inline', function () {
livewire(ListPosts::class)
->call(
'updateTableColumnState',
'title', // column name
$postId, // record ID
'updated title', // new value
);
 
$this->assertDatabaseHas(Post::class, [
'id' => $postId,
'title' => 'updated title',
]);
});

No comments yet…