Add admin-editable About page
Mirrors the existing Bio singleton pattern: a new `about` table/model, admin CRUD at /admin/about, and a public page at /about linked from both the header nav and the admin homepage. Content is wrapped in .e-content so it lays out correctly within the site's CSS grid. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013bzYwaDD8p3XNDMYKvXKrs
This commit is contained in:
parent
9532aae37e
commit
9e9fbdc127
12 changed files with 252 additions and 0 deletions
26
tests/Feature/AboutPageTest.php
Normal file
26
tests/Feature/AboutPageTest.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\About;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AboutPageTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
#[Test]
|
||||
public function about_page_shows_content(): void
|
||||
{
|
||||
About::factory()->create([
|
||||
'content' => 'This is the about page content.',
|
||||
]);
|
||||
|
||||
$this->get('/about')
|
||||
->assertSee('This is the about page content.');
|
||||
}
|
||||
}
|
||||
68
tests/Feature/Admin/AboutTest.php
Normal file
68
tests/Feature/Admin/AboutTest.php
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Admin;
|
||||
|
||||
use App\Models\About;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AboutTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
#[Test]
|
||||
public function admin_about_page_loads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
$response = $this->actingAs($user)
|
||||
->get('/admin/about');
|
||||
$response->assertSeeText('Edit About');
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function admin_can_create_about(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
$this->actingAs($user)
|
||||
->post('/admin/about', [
|
||||
'_method' => 'PUT',
|
||||
'content' => 'About content',
|
||||
]);
|
||||
$this->assertDatabaseHas('about', ['content' => 'About content']);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function admin_can_load_existing_about(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
$about = About::factory()->create([
|
||||
'content' => 'This is <em>my</em> about page. It uses <strong>HTML</strong>.',
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($user)
|
||||
->get('/admin/about');
|
||||
$response->assertSeeText('This is <em>my</em> about page. It uses <strong>HTML</strong>.');
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function admin_can_edit_about(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
$about = About::factory()->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->post('/admin/about', [
|
||||
'_method' => 'PUT',
|
||||
'content' => 'This about page has been edited',
|
||||
]);
|
||||
$this->assertDatabaseHas('about', [
|
||||
'content' => 'This about page has been edited',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue