MaxieWright
MaxieWright
FFilament
Created by MaxieWright on 12/30/2024 in #❓┊help
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);

});
4 replies