UPDATED TESTS
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Browser;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Laravel\Dusk\Browser;
|
||||
use Tests\Browser\Concerns\InteractsWithWmsData;
|
||||
use Tests\DuskTestCase;
|
||||
|
||||
class AuthBrowserTest extends DuskTestCase
|
||||
{
|
||||
use DatabaseMigrations;
|
||||
use InteractsWithWmsData;
|
||||
|
||||
public function test_login_page_renders_professional_auth_form(): void
|
||||
{
|
||||
$this->browse(function (Browser $browser): void {
|
||||
$browser->visit('/login')
|
||||
->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')
|
||||
->assertPathIs('/login');
|
||||
});
|
||||
}
|
||||
|
||||
public function test_platform_admin_can_login_and_logout(): void
|
||||
{
|
||||
$this->platformAdminUser();
|
||||
|
||||
$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')
|
||||
->assertSee('Platform')
|
||||
->click('.wms-user-card-button')
|
||||
->waitFor('[data-test="logout-button"]')
|
||||
->click('[data-test="logout-button"]')
|
||||
->waitForLocation('/')
|
||||
->assertPathIs('/');
|
||||
});
|
||||
}
|
||||
|
||||
public function test_tenant_user_login_routes_to_warehouse_dashboard(): void
|
||||
{
|
||||
$this->tenantUser();
|
||||
$this->seedWarehouse();
|
||||
|
||||
$this->browse(function (Browser $browser): void {
|
||||
$browser->visit('/login')
|
||||
->type('email', 'tenant.user@example.test')
|
||||
->type('password', $this->browserPassword)
|
||||
->press('Log in')
|
||||
->waitForLocation('/dashboard')
|
||||
->assertPathIs('/dashboard')
|
||||
->assertSee('Main Warehouse');
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user