mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 22:46:16 +00:00
#591 - profile, users and projects
This commit is contained in:
@ -2,12 +2,9 @@
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Web\Pages\Settings\Profile\Index;
|
||||
use App\Web\Pages\Settings\Profile\Widgets\ProfileInformation;
|
||||
use App\Web\Pages\Settings\Profile\Widgets\UpdatePassword;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Livewire\Livewire;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ProfileTest extends TestCase
|
||||
@ -19,44 +16,38 @@ public function test_profile_page_is_displayed(): void
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$this
|
||||
->get(Index::getUrl())
|
||||
->get(route('profile'))
|
||||
->assertSuccessful()
|
||||
->assertSee('Profile Information')
|
||||
->assertSee('Update Password')
|
||||
->assertSee('Browser Sessions')
|
||||
->assertSee('Two Factor Authentication');
|
||||
->assertInertia(fn (Assert $page) => $page->component('profile/index'));
|
||||
}
|
||||
|
||||
public function test_profile_information_can_be_updated(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
Livewire::test(ProfileInformation::class)
|
||||
->fill([
|
||||
'name' => 'Test',
|
||||
'email' => 'test@example.com',
|
||||
'timezone' => 'Europe/Berlin',
|
||||
])
|
||||
->call('submit');
|
||||
$this->patch(route('profile.update'), [
|
||||
'name' => 'Test',
|
||||
'email' => 'test@example.com',
|
||||
])
|
||||
->assertRedirect(route('profile'));
|
||||
|
||||
$this->user->refresh();
|
||||
|
||||
$this->assertSame('Test', $this->user->name);
|
||||
$this->assertSame('test@example.com', $this->user->email);
|
||||
$this->assertSame('Europe/Berlin', $this->user->timezone);
|
||||
}
|
||||
|
||||
public function test_password_can_be_updated(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
Livewire::test(UpdatePassword::class)
|
||||
->fill([
|
||||
'current_password' => 'password',
|
||||
'password' => 'new-password',
|
||||
'password_confirmation' => 'new-password',
|
||||
])
|
||||
->call('submit');
|
||||
$this->put(route('profile.password'), [
|
||||
'current_password' => 'password',
|
||||
'password' => 'new-password',
|
||||
'password_confirmation' => 'new-password',
|
||||
])
|
||||
->assertRedirect(route('profile'))
|
||||
->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertTrue(Hash::check('new-password', $this->user->refresh()->password));
|
||||
}
|
||||
@ -64,14 +55,11 @@ public function test_password_can_be_updated(): void
|
||||
public function test_correct_password_must_be_provided_to_update_password(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
Livewire::test(UpdatePassword::class)
|
||||
->fill([
|
||||
'current_password' => 'wrong-password',
|
||||
'password' => 'new-password',
|
||||
'password_confirmation' => 'new-password',
|
||||
])
|
||||
->call('submit')
|
||||
->assertHasErrors('current_password');
|
||||
$this->put(route('profile.password'), [
|
||||
'current_password' => 'wrong-password',
|
||||
'password' => 'new-password',
|
||||
'password_confirmation' => 'new-password',
|
||||
])
|
||||
->assertSessionHasErrors('current_password');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user