mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-10 07:34:06 -08:00
47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Browser;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
|
use Laravel\Dusk\Browser;
|
|
use Tests\DuskTestCase;
|
|
|
|
class LoginTest extends DuskTestCase
|
|
{
|
|
/**
|
|
* Test login
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testLoginPageLoadsAndUserCanLogin()
|
|
{
|
|
// Create a new user
|
|
$user = User::factory()->make();
|
|
|
|
// We override the existing password to use a hash of one we know
|
|
$user->password = '$2y$10$8o5W8fgAKJbN3Kz4taepeeRVgKsG8pkZ1L4eJfdEKrn2mgI/JgCJy';
|
|
|
|
// We want a user that is a superuser
|
|
$user->permissions = '{"superuser": 1}';
|
|
|
|
$user->save();
|
|
$this->browse(function (Browser $browser) {
|
|
$browser->visitRoute('login')
|
|
->assertSee(trans('auth/general.login_prompt'));
|
|
});
|
|
|
|
$this->browse(function ($browser) use ($user) {
|
|
$browser->visitRoute('login')
|
|
->type('username', $user->username)
|
|
->type('password', 'password')
|
|
->press(trans('auth/general.login'))
|
|
->assertPathIs('/');
|
|
$browser->screenshot('dashboard');
|
|
});
|
|
|
|
// Delete the user afterwards
|
|
$user->delete();
|
|
}
|
|
}
|