UPDATED TESTS wirr dusk

This commit is contained in:
Mark Gregory
2026-06-11 14:51:28 +01:00
parent cad45a870d
commit a55b98cf38
13 changed files with 300 additions and 359 deletions
+15 -18
View File
@@ -32,42 +32,39 @@ class AuthBrowserTest extends DuskTestCase
->type('email', 'platform.admin@example.test')
->type('password', 'wrong-password')
->press('Log in')
->waitForLocation('/login')
->waitForLocation('/login', 10)
->assertPathIs('/login');
});
}
public function test_platform_admin_can_login_and_logout(): void
public function test_platform_admin_session_reaches_admin_shell_and_can_logout(): void
{
$this->platformAdminUser();
$admin = $this->platformAdminUser();
$this->seedPlatformDashboardData();
$this->browse(function (Browser $browser): void {
$browser->visit('/login')
->type('email', 'platform.admin@example.test')
->type('password', $this->browserPassword)
->press('Log in')
->waitForLocation('/admin')
->assertPathIs('/admin')
$this->browse(function (Browser $browser) use ($admin): void {
$browser->loginAs($admin)
->visit('/admin')
->waitFor('.wms-app-shell', 10)
->assertSee('Platform')
->click('.wms-user-card-button')
->waitFor('[data-test="logout-button"]')
->click('[data-test="logout-button"]')
->waitForLocation('/')
->assertPathIs('/');
->assertPresent('form[action$="/logout"]')
->script('document.querySelector("form[action$=\\"/logout\\"]").submit();');
$browser->waitForLocation('/', 10);
});
}
public function test_tenant_user_login_routes_to_warehouse_dashboard(): void
{
$this->tenantUser();
$this->seedWarehouse();
$user = $this->tenantUser();
$this->seedWarehouse($user->company);
$this->browse(function (Browser $browser): void {
$browser->visit('/login')
->type('email', 'tenant.user@example.test')
->type('password', $this->browserPassword)
->press('Log in')
->waitForLocation('/dashboard')
->waitForLocation('/dashboard', 10)
->assertPathIs('/dashboard')
->assertSee('Main Warehouse');
});