new design with nice layout

This commit is contained in:
Mark Gregory
2026-11-20 07:19:23 +00:00
parent 1e7b41ae2d
commit 37bb7354fa
18 changed files with 381 additions and 141 deletions
+44 -21
View File
@@ -1,7 +1,9 @@
<?php
namespace Tests\Feature;
use App\Livewire\ContactForm;
use App\Livewire\Admin\Sections;
use App\Livewire\ContactForm;
use App\Models\ContactEnquiry;
use App\Models\SiteSection;
use App\Models\User;
@@ -9,43 +11,64 @@ use Database\Seeders\SiteContentSeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Livewire;
use Tests\TestCase;
class SiteExperienceTest extends TestCase {
class SiteExperienceTest extends TestCase
{
use RefreshDatabase;
public function test_homepage_displays_published_content(): void {
public function test_homepage_displays_published_content(): void
{
$this->seed(SiteContentSeeder::class);
$this->get('/')->assertOk()->assertSee('Digital experiences built to move your business forward.');
SiteSection::where('key','hero')->update(['is_visible'=>false]);
SiteSection::where('key', 'hero')->update(['is_visible' => false]);
$this->get('/')->assertOk()->assertDontSee('Digital experiences built to move your business forward.');
}
public function test_contact_form_validates_and_saves_enquiry(): void {
Livewire::test(ContactForm::class)->set('name','Test Client')->set('email','[email protected]')
->set('message','Please build a Laravel website for my business.')->call('submit')->assertHasNoErrors();
$this->assertDatabaseHas('contact_enquiries',['email'=>'[email protected]','is_read'=>false]);
public function test_contact_form_validates_and_saves_enquiry(): void
{
Livewire::test(ContactForm::class)->set('name', 'Test Client')->set('email', '[email protected]')
->set('message', 'Please build a Laravel website for my business.')->call('submit')->assertHasNoErrors();
$this->assertDatabaseHas('contact_enquiries', ['email' => '[email protected]', 'is_read' => false]);
}
public function test_guests_cannot_open_admin_dashboard(): void { $this->get('/admin')->assertRedirect(route('login')); }
public function test_non_admin_cannot_access_admin_pages(): void {
public function test_guests_cannot_open_admin_dashboard(): void
{
$this->get('/admin')->assertRedirect(route('login'));
}
public function test_non_admin_cannot_access_admin_pages(): void
{
$this->actingAs(User::factory()->create())->get('/admin')->assertForbidden();
}
public function test_admin_can_edit_site_content(): void {
$admin=User::factory()->create(['is_admin'=>true]); $this->actingAs($admin);
Livewire::test(Sections::class)->set('key','hero')->set('title','A better digital future')
->set('body','Custom messaging')->set('is_visible',true)->call('save')->assertHasNoErrors();
$this->assertDatabaseHas('site_sections',['key'=>'hero','title'=>'A better digital future']);
public function test_admin_can_edit_site_content(): void
{
$admin = User::factory()->create(['is_admin' => true]);
$this->actingAs($admin);
Livewire::test(Sections::class)->set('key', 'hero')->set('title', 'A better digital future')
->set('body', 'Custom messaging')->set('is_visible', true)->call('save')->assertHasNoErrors();
$this->assertDatabaseHas('site_sections', ['key' => 'hero', 'title' => 'A better digital future']);
}
public function test_dedicated_public_pages_render_with_navigation_and_content(): void {
public function test_dedicated_public_pages_render_with_navigation_and_content(): void
{
foreach (['services' => 'Digital services', 'expertise' => 'Deep engineering', 'approach' => 'A clear process'] as $url => $heading) {
$this->get('/'.$url)->assertOk()->assertSee($heading)->assertSee('Capability with purpose');
}
}
public function test_homepage_navigation_links_to_dedicated_pages(): void {
public function test_homepage_navigation_links_to_dedicated_pages(): void
{
$this->seed(SiteContentSeeder::class);
$this->get('/')->assertOk()->assertSee('href="'.route('services').'"', false)
->assertSee('href="'.route('expertise').'"', false)
->assertSee('href="'.route('approach').'"', false);
}
public function test_honeypot_rejects_spam(): void {
Livewire::test(ContactForm::class)->set('name','Spam')->set('email','[email protected]')
->set('message','Spam message example')->set('website','spambot')->call('submit')->assertHasErrors(['website']);
$this->assertSame(0,ContactEnquiry::count());
public function test_honeypot_rejects_spam(): void
{
Livewire::test(ContactForm::class)->set('name', 'Spam')->set('email', '[email protected]')
->set('message', 'Spam message example')->set('website', 'spambot')->call('submit')->assertHasErrors(['website']);
$this->assertSame(0, ContactEnquiry::count());
}
}