2025-12-28 20:18:27 +01:00
|
|
|
<?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)
|
2025-12-29 02:57:25 +01:00
|
|
|
->type('input[id="email"]', 'admin@test.com')
|
|
|
|
|
->type('input[id="password"]', 'password')
|
2025-12-28 20:18:27 +01:00
|
|
|
->press('Login')
|
|
|
|
|
->pause(3000)
|
|
|
|
|
->assertPathIs('/dashboard')
|
|
|
|
|
->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)
|
2025-12-29 02:57:25 +01:00
|
|
|
->type('input[id="email"]', 'admin@test.com')
|
|
|
|
|
->type('input[id="password"]', 'wrongpassword')
|
2025-12-28 20:18:27 +01:00
|
|
|
->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();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|