feat: add admin email configuration to app settings

delete: remove outdated Spatie media library decision document

docs: create new decision document for Spatie media library usage

docs: add testing strategy document for Pest4 and Dusk

test: implement login tests with Dusk for user authentication

chore: add .gitignore files for console, screenshots, and source directories
This commit is contained in:
jon brookes 2026-01-05 13:43:07 +00:00
parent aa39707e10
commit ff5ab3aa58
14 changed files with 189 additions and 1491 deletions

View file

@ -0,0 +1,98 @@
<?php
namespace Tests\Browser;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseTruncation;
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;
class LoginTest extends DuskTestCase
{
use DatabaseTruncation;
/**
* Dusk test panel.
*/
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');
}
public function test_login(): void
{
$user = $this->createTestUser("login-test@example.com");
$this->browse(function (Browser $browser) use ($user) {
$this->loginUser($browser, $user);
try {
$browser->assertPathIs('/dashboard'); // Or wherever successful login redirects
} catch (\Exception $e) {
$browser->pause(10000); // Pause for 10 seconds on failure to debug
throw $e;
}
});
}
/*
public function test_invalid_login(): void
{
$user = $this->createTestUser("invalid-email@example.com");
$this->browse(function (Browser $browser) use ($user) {
$this->loginUser($browser, $user);
try {
$browser->visit('/admin')
->waitForLocation('/admin')
->assertPathIs('/admin')
->assertTitleContains('Dashboard')
->assertDontSee('Forbidden')
->pause(1000);
} catch (\Exception $e) {
$browser->pause(1000); // Pause for 1 second on failure to debug
throw $e;
}
});
}
*/
public function test_access_admin_panel(): void
{
$user = $this->createTestUser("login-test@example.com");
$this->browse(function (Browser $browser) use ($user) {
$this->loginUser($browser, $user);
try {
$browser->visit('/admin')
->waitForLocation('/admin')
->assertPathIs('/admin')
->assertTitleContains('Dashboard')
->assertDontSee('Forbidden')
->pause(1000);
} catch (\Exception $e) {
$browser->pause(1000); // Pause for 1 second on failure to debug
throw $e;
}
});
}
}

2
tests/Browser/console/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore

2
tests/Browser/screenshots/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore

2
tests/Browser/source/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore