feat: implement user authentication traits

and tests for admin panel image uploads
This commit is contained in:
jon brookes 2026-01-05 16:37:06 +00:00
parent 4cb9d078b1
commit bef3ae7f41
5 changed files with 106 additions and 104 deletions

View file

@ -0,0 +1,38 @@
<?php
namespace Tests\Browser\Concerns;
use App\Models\User;
use Laravel\Dusk\Browser;
trait AuthenticatesUsers
{
private function createTestUser(string $email): User
{
return User::factory()->create([
'email' => $email,
'password' => bcrypt('password'),
'two_factor_secret' => null,
'two_factor_recovery_codes' => null,
]);
}
private function loginUser(Browser $browser, User $user): void
{
$browser->visit('/login')
->type('email', $user->email)
->type('password', 'password')
->press('Log in')
->waitForLocation('/dashboard');
}
private function assertWithDebugPause(Browser $browser, callable $assertions, int $pauseMs = 10000): void
{
try {
$assertions($browser);
} catch (\Exception $e) {
$browser->pause($pauseMs);
throw $e;
}
}
}