Restore action test not working
I am writing tests for relation manager's soft delete functionality. The RestoreAction is somehow not working.
it('can restore contact', function () {
$admin = Admin::factory()
->has(Contact::factory()->count(1))
->create();
$contact = $admin->contacts->first();
livewire(ContactsRelationManager::class, [
'ownerRecord' => $admin,
'pageClass' => EditAdmin::class,
])
->mountTableAction(DeleteAction::class, $contact)
->callMountedTableAction();
livewire(ContactsRelationManager::class, [
'ownerRecord' => $admin,
'pageClass' => EditAdmin::class,
])
->mountTableAction(RestoreAction::class, $contact)
->callMountedTableAction();
$this->assertDatabaseHas(Contact::class, [
'id' => $contact->id,
'deleted_at' => null,
]);
});
1 Reply
Solution
Fixed just need to add ->filterTable('trashed') when we are restoring.