-
+
diff --git a/resources/views/livewire/account.blade.php b/resources/views/livewire/account.blade.php
index 158011a0fe..d0f622a276 100644
--- a/resources/views/livewire/account.blade.php
+++ b/resources/views/livewire/account.blade.php
@@ -8,15 +8,15 @@
-
+
{{ __('Optional') }}
-
+
-
+
{{ __('Optional') }}
@@ -26,7 +26,7 @@
-
+
diff --git a/src/Http/Livewire/Account.php b/src/Http/Livewire/Account.php
index f5c71cd03c..d230bffe43 100644
--- a/src/Http/Livewire/Account.php
+++ b/src/Http/Livewire/Account.php
@@ -26,7 +26,8 @@ class Account extends Component
'required',
'email',
],
- 'password' => 'nullable',
+ 'password' => 'nullable|required_with:password_confirmation|min:8|confirmed',
+ 'password_confirmation' => 'nullable|same:password',
];
public function updated($user)
@@ -37,8 +38,6 @@ class Account extends Component
'email',
Rule::unique('users', 'email')->ignore($this->user->id),
],
- 'password' => 'nullable|required_with:password_confirmation|min:8',
- 'password_confirmation' => 'nullable|same:password',
]);
}
diff --git a/tests/Feature/ProfileAccountTest.php b/tests/Feature/ProfileAccountTest.php
new file mode 100644
index 0000000000..5327e802f4
--- /dev/null
+++ b/tests/Feature/ProfileAccountTest.php
@@ -0,0 +1,112 @@
+user = User::factory()->create();
+ }
+
+ public function test_name_is_required()
+ {
+ $this->accountComponent()
+ ->set('user.name', '')
+ ->call('submit')
+ ->assertHasErrors(['user.name' => 'required']);
+ }
+
+ public function test_name_is_minimum_two_characters()
+ {
+ $this->accountComponent()
+ ->set('user.name', 'a')
+ ->call('submit')
+ ->assertHasErrors(['user.name' => 'min']);
+ }
+
+ public function test_email_is_required()
+ {
+ $this->accountComponent()
+ ->set('user.email', '')
+ ->call('submit')
+ ->assertHasErrors(['user.email' => 'required']);
+ }
+
+ public function test_email_is_valid_email()
+ {
+ $this->accountComponent()
+ ->set('user.email', 'Something')
+ ->call('submit')
+ ->assertHasErrors(['user.email' => 'email']);
+ }
+
+ public function test_email_is_unique()
+ {
+ User::factory()->create(['email' => 'test@example.com']);
+
+ $this->accountComponent()
+ ->set('user.email', 'test@example.com')
+ ->assertHasErrors(['user.email' => 'unique']);
+ }
+
+ public function test_password_may_be_left_blank()
+ {
+ $this->accountComponent()
+ ->set('password', '')
+ ->call('submit')
+ ->assertHasNoErrors(['password' => 'nullable']);
+ }
+
+ public function test_password_is_minimum_eight_characters()
+ {
+ $this->accountComponent()
+ ->set('password', 'test')
+ ->call('submit')
+ ->assertHasErrors(['password' => 'min']);
+ }
+
+ public function test_password_must_be_confirmed()
+ {
+ $this->accountComponent()
+ ->set('password', 'test')
+ ->call('submit')
+ ->assertHasErrors(['password' => 'confirmed']);
+ }
+
+ public function test_password_confirmation_may_be_left_blank()
+ {
+ $this->accountComponent()
+ ->set('password_confirmation', '')
+ ->call('submit')
+ ->assertHasNoErrors(['password_confirmation' => 'nullable']);
+ }
+
+ public function test_password_confirmation_matches_password()
+ {
+ $this->accountComponent()
+ ->set('password', 'test')
+ ->set('password_confirmation', 'test2')
+ ->call('submit')
+ ->assertHasErrors(['password_confirmation' => 'same']);
+ }
+
+ public function test_account_saved()
+ {
+ $this->accountComponent()
+ ->call('submit')
+ ->assertDispatchedBrowserEvent('notify', __('Account saved!'));
+ }
+
+ public function accountComponent()
+ {
+ return Livewire::test(Account::class, ['user' => $this->user]);
+ }
+}
\ No newline at end of file
diff --git a/tests/Feature/ProfileTest.php b/tests/Feature/ProfileTest.php
new file mode 100644
index 0000000000..d6a1397288
--- /dev/null
+++ b/tests/Feature/ProfileTest.php
@@ -0,0 +1,27 @@
+user = User::factory()->create();
+ }
+
+ public function test_can_see_profile_and_user_account_form()
+ {
+ Livewire::actingAs($this->user)
+ ->test(Profile::class)
+ ->assertSee(__('Profile'))
+ ->assertSeeLivewire('filament-account');
+ }
+}
\ No newline at end of file