56 lines
2 KiB
PHP
56 lines
2 KiB
PHP
|
|
<?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();
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|