Skip to content

Commit 96b829a

Browse files
committed
chore: use livewire tests
1 parent f28bd5d commit 96b829a

1 file changed

Lines changed: 28 additions & 26 deletions

File tree

tests/Feature/Filament/CreatePolydockAppInstanceTest.php

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use App\Models\User;
1111
use App\Models\UserRemoteRegistration;
1212
use Filament\Facades\Filament;
13+
use Livewire\Livewire;
1314
use Illuminate\Foundation\Testing\RefreshDatabase;
1415
use Illuminate\Support\Facades\Queue;
1516
use Tests\TestCase;
@@ -50,40 +51,21 @@ public function test_admin_can_create_app_instance(): void
5051
{
5152
Queue::fake();
5253

53-
// Directly call the create method on the page instance
54-
$page = new CreatePolydockAppInstance;
55-
$page->data = [
56-
'email' => 'newuser@example.com',
57-
'first_name' => 'John',
58-
'last_name' => 'Doe',
59-
'organization' => 'Test Org',
60-
'trial_app' => $this->storeApp->uuid,
61-
'is_trial' => true,
62-
'aup_and_privacy_acceptance' => true,
63-
'opt_in_to_product_updates' => true,
64-
];
65-
66-
// Mock form validation
6754
$this->actingAs($this->admin);
6855

69-
// Create registration directly as the form would
70-
$registration = UserRemoteRegistration::create([
71-
'email' => 'newuser@example.com',
72-
'request_data' => [
56+
Livewire::test(CreatePolydockAppInstance::class)
57+
->fillForm([
7358
'email' => 'newuser@example.com',
7459
'first_name' => 'John',
7560
'last_name' => 'Doe',
7661
'organization' => 'Test Org',
77-
'register_type' => 'REQUEST_TRIAL',
7862
'trial_app' => $this->storeApp->uuid,
79-
'aup_and_privacy_acceptance' => 1,
80-
'opt_in_to_product_updates' => 1,
81-
'admin_created' => true,
8263
'is_trial' => true,
83-
],
84-
]);
85-
86-
ProcessUserRemoteRegistration::dispatch($registration);
64+
'aup_and_privacy_acceptance' => true,
65+
'opt_in_to_product_updates' => true,
66+
])
67+
->call('create')
68+
->assertHasNoFormErrors();
8769

8870
// Verify registration was created
8971
$this->assertDatabaseHas('user_remote_registrations', [
@@ -94,6 +76,26 @@ public function test_admin_can_create_app_instance(): void
9476
Queue::assertPushed(ProcessUserRemoteRegistration::class);
9577
}
9678

79+
public function test_create_form_validates_required_fields(): void
80+
{
81+
$this->actingAs($this->admin);
82+
83+
Livewire::test(CreatePolydockAppInstance::class)
84+
->fillForm([
85+
'email' => '',
86+
'first_name' => '',
87+
'last_name' => '',
88+
'trial_app' => null,
89+
])
90+
->call('create')
91+
->assertHasFormErrors([
92+
'email' => 'required',
93+
'first_name' => 'required',
94+
'last_name' => 'required',
95+
'trial_app' => 'required',
96+
]);
97+
}
98+
9799
public function test_registration_includes_admin_created_flag(): void
98100
{
99101
Queue::fake();

0 commit comments

Comments
 (0)