F
Filament2mo ago
swilla

Reactive Forms Testing CI

I have a test for a form component that is working well locally, but I cannot get it to pass in GitHub Actions. I've tried so many different iterations without any luck. Here is the error that is returned in GitHub Actions:
FAIL Tests\Feature\Filament\ReservationCreateTest
⨯ webhook is dispatched when creating reservation for rentable with w… 5.17s
────────────────────────────────────────────────────────────────────────────
FAILED Tests\Feature\Filament\ReservationCreateTest > webhook is dispatc…
Component has errors: "data.rentable"
Failed asserting that false is true.

at vendor/livewire/livewire/src/Features/SupportValidation/TestsValidation.php:109
105▕ {
106▕ $errors = $this->errors();
107▕
108▕ if (empty($keys)) {
➜ 109▕ PHPUnit::assertTrue($errors->isEmpty(), 'Component has errors: "'.implode('", "', $errors->keys()).'"');
110▕
111▕ return $this;
112▕ }
113▕

+4 vendor frames
5 tests/Feature/Filament/ReservationCreateTest.php:108


Tests: 1 failed, 2 skipped, 17 passed, 53 pending (49 assertions)
Duration: 71.91s
FAIL Tests\Feature\Filament\ReservationCreateTest
⨯ webhook is dispatched when creating reservation for rentable with w… 5.17s
────────────────────────────────────────────────────────────────────────────
FAILED Tests\Feature\Filament\ReservationCreateTest > webhook is dispatc…
Component has errors: "data.rentable"
Failed asserting that false is true.

at vendor/livewire/livewire/src/Features/SupportValidation/TestsValidation.php:109
105▕ {
106▕ $errors = $this->errors();
107▕
108▕ if (empty($keys)) {
➜ 109▕ PHPUnit::assertTrue($errors->isEmpty(), 'Component has errors: "'.implode('", "', $errors->keys()).'"');
110▕
111▕ return $this;
112▕ }
113▕

+4 vendor frames
5 tests/Feature/Filament/ReservationCreateTest.php:108


Tests: 1 failed, 2 skipped, 17 passed, 53 pending (49 assertions)
Duration: 71.91s
2 Replies
swilla
swillaOP2mo ago
I fixed this by setting everything all at once:
// Create the reservation via Livewire
$livewire = livewire(ReservationCreate::class)
->set('rentable', $rentable);

$data = [
'location' => $this->location->id,
'rentable' => $rentable->id,
'name' => 'Test Reservation',
'date' => $start->format('Y-m-d H:i:s'),
'start' => $start->format('Y-m-d H:i:s'),
'end' => $end->format('Y-m-d H:i:s'),
'credit' => min($price, $this->team->credit),
];

$livewire->set('data', $data);
$livewire->fillForm($data);

// Submit the form
$livewire->call('submit');

$livewire->assertHasNoFormErrors();
// Create the reservation via Livewire
$livewire = livewire(ReservationCreate::class)
->set('rentable', $rentable);

$data = [
'location' => $this->location->id,
'rentable' => $rentable->id,
'name' => 'Test Reservation',
'date' => $start->format('Y-m-d H:i:s'),
'start' => $start->format('Y-m-d H:i:s'),
'end' => $end->format('Y-m-d H:i:s'),
'credit' => min($price, $this->team->credit),
];

$livewire->set('data', $data);
$livewire->fillForm($data);

// Submit the form
$livewire->call('submit');

$livewire->assertHasNoFormErrors();
LeandroFerreira
LeandroFerreira2mo ago
I think it is a test config issue.. you can confirm it using app()->runningUnitTests(). It should return true

Did you find this page helpful?