feature - 11 - Add login test
This commit is contained in:
parent
3c32d49977
commit
9e22c23208
2 changed files with 60 additions and 0 deletions
|
|
@ -24,6 +24,10 @@ class Planner extends Authenticatable
|
|||
'password', 'remember_token',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'password' => 'hashed',
|
||||
];
|
||||
|
||||
public function schedules(): HasMany
|
||||
{
|
||||
return $this->hasMany(Schedule::class);
|
||||
|
|
|
|||
56
tests/Browser/LoginTest.php
Normal file
56
tests/Browser/LoginTest.php
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Browser;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
use Tests\DuskTestCase;
|
||||
use App\Models\Planner;
|
||||
|
||||
class LoginTest extends DuskTestCase
|
||||
{
|
||||
public function testSuccessfulLogin(): void
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
$browser->visit('http://dishplanner_app:8000/login')
|
||||
->waitFor('input[id="email"]', 5)
|
||||
->type('input[id="email"]', 'test.20251228124357@example.com')
|
||||
->type('input[id="password"]', 'SecurePassword123!')
|
||||
->press('Login')
|
||||
->pause(3000)
|
||||
->assertPathIs('/dashboard')
|
||||
->assertSee('Welcome Test User 20251228124357!')
|
||||
->assertAuthenticated()
|
||||
->visit('http://dishplanner_app:8000/logout');
|
||||
});
|
||||
}
|
||||
|
||||
public function testLoginWithWrongCredentials(): void
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
$browser->driver->manage()->deleteAllCookies();
|
||||
$browser->visit('http://dishplanner_app:8000/login')
|
||||
->waitFor('input[id="email"]', 5)
|
||||
->type('input[id="email"]', 'test.20251228124357@example.com')
|
||||
->type('input[id="password"]', 'WrongPassword123!')
|
||||
->press('Login')
|
||||
->pause(2000)
|
||||
->assertPathIs('/login')
|
||||
->assertSee('These credentials do not match our records')
|
||||
->assertGuest();
|
||||
});
|
||||
}
|
||||
|
||||
public function testLoginWithBlankFields(): void
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
$browser->driver->manage()->deleteAllCookies();
|
||||
$browser->visit('http://dishplanner_app:8000/login')
|
||||
->waitFor('input[id="email"]', 5)
|
||||
->press('Login')
|
||||
->pause(2000)
|
||||
->assertPathIs('/login')
|
||||
->assertSee('The email field is required')
|
||||
->assertGuest();
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue