story 6.8 and fixed the redundunt options issue
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
use App\Mail\TestEmail;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Livewire\Volt\Volt;
|
||||
|
||||
test('profile page is displayed', function () {
|
||||
@@ -17,6 +19,7 @@ test('profile information can be updated', function () {
|
||||
$response = Volt::test('settings.profile')
|
||||
->set('full_name', 'Test User')
|
||||
->set('email', 'test@example.com')
|
||||
->set('preferred_language', 'en')
|
||||
->call('updateProfileInformation');
|
||||
|
||||
$response->assertHasNoErrors();
|
||||
@@ -25,6 +28,7 @@ test('profile information can be updated', function () {
|
||||
|
||||
expect($user->full_name)->toEqual('Test User');
|
||||
expect($user->email)->toEqual('test@example.com');
|
||||
expect($user->preferred_language)->toEqual('en');
|
||||
expect($user->email_verified_at)->toBeNull();
|
||||
});
|
||||
|
||||
@@ -43,6 +47,98 @@ test('email verification status is unchanged when email address is unchanged', f
|
||||
expect($user->refresh()->email_verified_at)->not->toBeNull();
|
||||
});
|
||||
|
||||
// ===========================================
|
||||
// Preferred Language Tests
|
||||
// ===========================================
|
||||
|
||||
test('user can update preferred language', function () {
|
||||
$user = User::factory()->create(['preferred_language' => 'ar']);
|
||||
|
||||
$this->actingAs($user);
|
||||
|
||||
Volt::test('settings.profile')
|
||||
->set('preferred_language', 'en')
|
||||
->call('updateProfileInformation')
|
||||
->assertHasNoErrors();
|
||||
|
||||
expect($user->fresh()->preferred_language)->toBe('en');
|
||||
});
|
||||
|
||||
test('preferred language validates allowed values', function () {
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->actingAs($user);
|
||||
|
||||
Volt::test('settings.profile')
|
||||
->set('preferred_language', 'fr')
|
||||
->call('updateProfileInformation')
|
||||
->assertHasErrors(['preferred_language']);
|
||||
});
|
||||
|
||||
test('component initializes with user preferred language', function () {
|
||||
$user = User::factory()->create(['preferred_language' => 'en']);
|
||||
|
||||
$this->actingAs($user);
|
||||
|
||||
$component = Volt::test('settings.profile');
|
||||
|
||||
expect($component->get('preferred_language'))->toBe('en');
|
||||
});
|
||||
|
||||
// ===========================================
|
||||
// Test Email Tests (Admin Only)
|
||||
// ===========================================
|
||||
|
||||
test('admin can send test email', function () {
|
||||
Mail::fake();
|
||||
|
||||
$admin = User::factory()->admin()->create();
|
||||
|
||||
$this->actingAs($admin);
|
||||
|
||||
Volt::test('settings.profile')
|
||||
->call('sendTestEmail')
|
||||
->assertHasNoErrors();
|
||||
|
||||
Mail::assertSent(TestEmail::class, fn ($mail) => $mail->hasTo($admin->email));
|
||||
});
|
||||
|
||||
test('test email uses admin preferred language', function () {
|
||||
Mail::fake();
|
||||
|
||||
$admin = User::factory()->admin()->create(['preferred_language' => 'ar']);
|
||||
|
||||
$this->actingAs($admin);
|
||||
|
||||
Volt::test('settings.profile')
|
||||
->call('sendTestEmail');
|
||||
|
||||
Mail::assertSent(TestEmail::class, fn ($mail) => $mail->locale === 'ar');
|
||||
});
|
||||
|
||||
test('non-admin cannot send test email', function () {
|
||||
Mail::fake();
|
||||
|
||||
$client = User::factory()->individual()->create();
|
||||
|
||||
$this->actingAs($client);
|
||||
|
||||
Volt::test('settings.profile')
|
||||
->call('sendTestEmail');
|
||||
|
||||
Mail::assertNothingSent();
|
||||
});
|
||||
|
||||
test('admin sees email configuration section', function () {
|
||||
$admin = User::factory()->admin()->create();
|
||||
|
||||
$this->actingAs($admin)
|
||||
->get(route('profile.edit'))
|
||||
->assertOk()
|
||||
->assertSee(config('mail.from.name'))
|
||||
->assertSee(config('mail.from.address'));
|
||||
});
|
||||
|
||||
test('user can delete their account', function () {
|
||||
$user = User::factory()->create();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user