mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
migrating tests (Metrics, NotificationChannels, PHP, Profile and Projects)
This commit is contained in:
@ -2,8 +2,12 @@
|
||||
|
||||
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 Tests\TestCase;
|
||||
|
||||
class ProfileTest extends TestCase
|
||||
@ -15,7 +19,7 @@ public function test_profile_page_is_displayed(): void
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$this
|
||||
->get(route('profile'))
|
||||
->get(Index::getUrl())
|
||||
->assertSuccessful()
|
||||
->assertSee('Profile Information')
|
||||
->assertSee('Update Password')
|
||||
@ -26,11 +30,13 @@ public function test_profile_information_can_be_updated(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$this->post(route('profile.info'), [
|
||||
'name' => 'Test',
|
||||
'email' => 'test@example.com',
|
||||
'timezone' => 'Europe/Berlin',
|
||||
]);
|
||||
Livewire::test(ProfileInformation::class)
|
||||
->fill([
|
||||
'name' => 'Test',
|
||||
'email' => 'test@example.com',
|
||||
'timezone' => 'Europe/Berlin',
|
||||
])
|
||||
->call('submit');
|
||||
|
||||
$this->user->refresh();
|
||||
|
||||
@ -43,11 +49,13 @@ public function test_password_can_be_updated(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$this->post(route('profile.password'), [
|
||||
'current_password' => 'password',
|
||||
'password' => 'new-password',
|
||||
'password_confirmation' => 'new-password',
|
||||
]);
|
||||
Livewire::test(UpdatePassword::class)
|
||||
->fill([
|
||||
'current_password' => 'password',
|
||||
'password' => 'new-password',
|
||||
'password_confirmation' => 'new-password',
|
||||
])
|
||||
->call('submit');
|
||||
|
||||
$this->assertTrue(Hash::check('new-password', $this->user->refresh()->password));
|
||||
}
|
||||
@ -56,10 +64,13 @@ public function test_correct_password_must_be_provided_to_update_password(): voi
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$this->post(route('profile.password'), [
|
||||
'current_password' => 'wrong-password',
|
||||
'password' => 'new-password',
|
||||
'password_confirmation' => 'new-password',
|
||||
])->assertSessionHasErrors('current_password');
|
||||
Livewire::test(UpdatePassword::class)
|
||||
->fill([
|
||||
'current_password' => 'wrong-password',
|
||||
'password' => 'new-password',
|
||||
'password_confirmation' => 'new-password',
|
||||
])
|
||||
->call('submit')
|
||||
->assertHasErrors('current_password');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user