77 lines
2.4 KiB
PHP
77 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace Tests\Browser;
|
|
|
|
use Laravel\Dusk\Browser;
|
|
use Tests\Browser\Concerns\InteractsWithWmsBrowser;
|
|
use Tests\Browser\Concerns\InteractsWithWmsData;
|
|
use Tests\DuskTestCase;
|
|
|
|
class AuthBrowserTest extends DuskTestCase
|
|
{
|
|
use InteractsWithWmsBrowser;
|
|
use InteractsWithWmsData;
|
|
|
|
public function test_login_page_renders_professional_auth_form(): void
|
|
{
|
|
$this->browse(function (Browser $browser): void {
|
|
$browser->visit('/login')
|
|
->waitFor('input[name="email"]', 10)
|
|
->assertSee('Log in')
|
|
->assertPresent('input[name="email"]')
|
|
->assertPresent('input[name="password"]')
|
|
->assertPresent('[data-test="login-button"]');
|
|
});
|
|
}
|
|
|
|
public function test_invalid_login_stays_on_login_page(): void
|
|
{
|
|
$this->platformAdminUser();
|
|
|
|
$this->browse(function (Browser $browser): void {
|
|
$browser->visit('/login')
|
|
->type('email', 'platform.admin@example.test')
|
|
->type('password', 'wrong-password')
|
|
->press('Log in')
|
|
->waitForLocation('/login', 10)
|
|
->assertPathIs('/login');
|
|
});
|
|
}
|
|
|
|
public function test_platform_admin_session_reaches_admin_shell_and_can_logout(): void
|
|
{
|
|
$admin = $this->platformAdminUser();
|
|
$this->seedPlatformDashboardData();
|
|
|
|
$this->browse(function (Browser $browser) use ($admin): void {
|
|
$browser->loginAs($admin)
|
|
->visit('/admin')
|
|
->waitFor('.wms-app-shell', 10)
|
|
->assertSee('Platform')
|
|
->assertPresent('form[action$="/logout"]');
|
|
|
|
$this->removeDebugbar($browser);
|
|
|
|
$browser->script('document.querySelector("form[action$=\\"/logout\\"]")?.submit();');
|
|
|
|
$browser->waitUntil(
|
|
'window.location.pathname === "/" || window.location.pathname === "/login" || ! document.querySelector(".wms-app-shell")',
|
|
15
|
|
);
|
|
});
|
|
}
|
|
|
|
public function test_tenant_user_session_reaches_warehouse_dashboard(): void
|
|
{
|
|
$user = $this->tenantUser();
|
|
$this->seedWarehouse($user->company);
|
|
|
|
$this->browse(function (Browser $browser) use ($user): void {
|
|
$browser->loginAs($user)
|
|
->visit('/dashboard')
|
|
->waitFor('.wms-page-hero', 10)
|
|
->assertPresent('.wms-page-hero');
|
|
});
|
|
}
|
|
}
|