Initial Commit
tests / ci (push) Canceled after 0s

This commit is contained in:
Mark Gregory
2026-11-24 22:01:45 +00:00
commit 65de7abdbc
125 changed files with 21667 additions and 0 deletions
@@ -0,0 +1,111 @@
<?php
use App\Livewire\Settings\Profile;
use App\Models\User;
use Livewire\Livewire;
test('profile page is displayed', function () {
$this->actingAs($user = User::factory()->create());
$this->get('/settings/profile')->assertOk();
});
test('profile information can be updated', function () {
$user = User::factory()->create();
$this->actingAs($user);
$response = Livewire::test(Profile::class)
->set('name', 'Test User')
->set('email', '[email protected]')
->call('updateProfileInformation');
$response->assertHasNoErrors();
$user->refresh();
expect($user->name)->toEqual('Test User');
expect($user->email)->toEqual('[email protected]');
expect($user->email_verified_at)->toBeNull();
});
test('email is stored in lowercase so the user can still log in', function () {
$user = User::factory()->create();
$this->actingAs($user);
Livewire::test(Profile::class)
->set('name', 'Test User')
->set('email', '[email protected]')
->call('updateProfileInformation')
->assertHasNoErrors();
expect($user->refresh()->email)->toEqual('[email protected]');
$this->post(route('logout'));
$this->post(route('login.store'), [
'email' => '[email protected]',
'password' => 'password',
]);
$this->assertAuthenticatedAs($user);
});
test('email must be unique regardless of case', function () {
User::factory()->create(['email' => '[email protected]']);
$this->actingAs(User::factory()->create());
Livewire::test(Profile::class)
->set('name', 'Test User')
->set('email', '[email protected]')
->call('updateProfileInformation')
->assertHasErrors(['email']);
});
test('email verification status is unchanged when email address is unchanged', function () {
$user = User::factory()->create();
$this->actingAs($user);
$response = Livewire::test(Profile::class)
->set('name', 'Test User')
->set('email', $user->email)
->call('updateProfileInformation');
$response->assertHasNoErrors();
expect($user->refresh()->email_verified_at)->not->toBeNull();
});
test('user can delete their account', function () {
$user = User::factory()->create();
$this->actingAs($user);
$response = Livewire::test('settings.delete-user-form')
->set('password', 'password')
->call('deleteUser');
$response
->assertHasNoErrors()
->assertRedirect('/');
expect($user->fresh())->toBeNull();
expect(auth()->check())->toBeFalse();
});
test('correct password must be provided to delete account', function () {
$user = User::factory()->create();
$this->actingAs($user);
$response = Livewire::test('settings.delete-user-form')
->set('password', 'wrong-password')
->call('deleteUser');
$response->assertHasErrors(['password']);
expect($user->fresh())->not->toBeNull();
});