Failing test when calling testing a table action

I encounter a failing test when testing a custom table action. Specifically, the test fails on the final assertion when I call the update method on a model before invoking the callTableAction method. Problem: The test fails on the final expectation, but the table action works correctly in the browser. Also, I have other tests with custom table actions that pass once nothing is called before invoking the callTableAction. Can someone help me understand why the test is failing?
php

it('extends the expiry date of an expired invitation', function () {

$this->invitation->update([
'expires_at' => now()->subDays(1),
'status' => InvitationStatus::Expired,
]);

$this->invitation->refresh();

expect($this->invitation->expiryDatePassed())->toBeTrue()
->and($this->invitation->status)->toBe(InvitationStatus::Expired);

Livewire::test(ListInvitations::class)
->callTableAction('extendExpiryDate', $this->invitation)
->assertHasNoActionErrors();

$this->invitation->refresh();

// Fails Here
expect($this->invitation->expires_at->isFuture())->toBeTrue()
->and($this->invitation->status)->toBe(InvitationStatus::Pending);

});
php

it('extends the expiry date of an expired invitation', function () {

$this->invitation->update([
'expires_at' => now()->subDays(1),
'status' => InvitationStatus::Expired,
]);

$this->invitation->refresh();

expect($this->invitation->expiryDatePassed())->toBeTrue()
->and($this->invitation->status)->toBe(InvitationStatus::Expired);

Livewire::test(ListInvitations::class)
->callTableAction('extendExpiryDate', $this->invitation)
->assertHasNoActionErrors();

$this->invitation->refresh();

// Fails Here
expect($this->invitation->expires_at->isFuture())->toBeTrue()
->and($this->invitation->status)->toBe(InvitationStatus::Pending);

});
2 Replies
LeandroFerreira
LeandroFerreira2mo ago
I believe this is a specific test in your application. Maybe you could create a minimal repository on GitHub to reproduce the issue...
MaxieWright
MaxieWrightOP2mo ago
Thank you very much! I will work on producing the minimal repository.

Did you find this page helpful?