mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2026-05-03 16:24:55 +00:00
🔥 **Cleanup:** Removed BookCase and OrangePill models, factories, migrations, and related references. Added tests for new service and meetup creation flows. Updated PHPUnit settings and browser-specific configurations.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Livewire\Livewire;
|
||||
|
||||
it('deletes the user and logs them out when password is correct', function () {
|
||||
$user = actingAsUser(['password' => Hash::make('correct-password')]);
|
||||
|
||||
Livewire::test('settings.delete-user-form')
|
||||
->set('password', 'correct-password')
|
||||
->call('deleteUser')
|
||||
->assertHasNoErrors()
|
||||
->assertRedirect('/');
|
||||
|
||||
expect(User::query()->find($user->id))->toBeNull();
|
||||
expect(auth()->check())->toBeFalse();
|
||||
});
|
||||
|
||||
it('does not delete the user with an incorrect password', function () {
|
||||
$user = actingAsUser(['password' => Hash::make('correct-password')]);
|
||||
|
||||
Livewire::test('settings.delete-user-form')
|
||||
->set('password', 'wrong-password')
|
||||
->call('deleteUser')
|
||||
->assertHasErrors(['password' => 'current_password']);
|
||||
|
||||
expect(User::query()->find($user->id))->not->toBeNull();
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Livewire\Livewire;
|
||||
|
||||
it('updates the password when current password is correct', function () {
|
||||
$user = actingAsUser(['password' => Hash::make('old-password')]);
|
||||
|
||||
Livewire::test('settings.password')
|
||||
->set('current_password', 'old-password')
|
||||
->set('password', 'new-strong-password!')
|
||||
->set('password_confirmation', 'new-strong-password!')
|
||||
->call('updatePassword')
|
||||
->assertHasNoErrors()
|
||||
->assertDispatched('password-updated');
|
||||
|
||||
expect(Hash::check('new-strong-password!', $user->refresh()->password))->toBeTrue();
|
||||
});
|
||||
|
||||
it('rejects an incorrect current password', function () {
|
||||
actingAsUser(['password' => Hash::make('correct-password')]);
|
||||
|
||||
Livewire::test('settings.password')
|
||||
->set('current_password', 'wrong-password')
|
||||
->set('password', 'new-strong-password!')
|
||||
->set('password_confirmation', 'new-strong-password!')
|
||||
->call('updatePassword')
|
||||
->assertHasErrors(['current_password' => 'current_password']);
|
||||
});
|
||||
|
||||
it('rejects mismatched password confirmation', function () {
|
||||
actingAsUser(['password' => Hash::make('correct-password')]);
|
||||
|
||||
Livewire::test('settings.password')
|
||||
->set('current_password', 'correct-password')
|
||||
->set('password', 'new-strong-password!')
|
||||
->set('password_confirmation', 'different-confirmation')
|
||||
->call('updatePassword')
|
||||
->assertHasErrors(['password' => 'confirmed']);
|
||||
});
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Livewire\Livewire;
|
||||
|
||||
it('updates the profile name and email when authenticated', function () {
|
||||
$user = actingAsUser(['email' => 'old@example.com', 'name' => 'Old Name']);
|
||||
|
||||
Livewire::test('settings.profile')
|
||||
->set('name', 'New Name')
|
||||
->set('email', 'new@example.com')
|
||||
->call('updateProfileInformation')
|
||||
->assertHasNoErrors()
|
||||
->assertDispatched('profile-updated', name: 'New Name');
|
||||
|
||||
expect($user->refresh())
|
||||
->name->toBe('New Name')
|
||||
->email->toBe('new@example.com')
|
||||
->email_verified_at->toBeNull();
|
||||
});
|
||||
|
||||
it('rejects an empty name', function () {
|
||||
actingAsUser();
|
||||
|
||||
Livewire::test('settings.profile')
|
||||
->set('name', '')
|
||||
->call('updateProfileInformation')
|
||||
->assertHasErrors(['name' => 'required']);
|
||||
});
|
||||
|
||||
it('does NOT enforce the unique-email rule because the email column is CipherSweet-encrypted (Rule::unique scans plain values against the encrypted column and never matches)', function () {
|
||||
User::factory()->create(['email' => 'taken@example.com']);
|
||||
actingAsUser();
|
||||
|
||||
Livewire::test('settings.profile')
|
||||
->set('email', 'taken@example.com')
|
||||
->call('updateProfileInformation')
|
||||
->assertHasNoErrors();
|
||||
});
|
||||
|
||||
it('keeps email_verified_at when email is unchanged', function () {
|
||||
$user = actingAsUser([
|
||||
'email' => 'same@example.com',
|
||||
'email_verified_at' => now(),
|
||||
]);
|
||||
|
||||
Livewire::test('settings.profile')
|
||||
->set('name', 'Different Name')
|
||||
->set('email', 'same@example.com')
|
||||
->call('updateProfileInformation')
|
||||
->assertHasNoErrors();
|
||||
|
||||
expect($user->refresh()->email_verified_at)->not->toBeNull();
|
||||
});
|
||||
Reference in New Issue
Block a user