+
+
+
+ {{ __('home.posts_title') }}
+
+
+
+
+ @foreach($latestPosts as $post)
+
+
+
+
+ {{ $post->getExcerpt() }}
+
+
+ {{ __('home.read_more') }} →
+
+
+ @endforeach
+
+
+
+
+
+ @endif
+
diff --git a/routes/web.php b/routes/web.php
index e2bc9dc..79bec36 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -7,9 +7,7 @@ use Illuminate\Support\Facades\Route;
use Laravel\Fortify\Features;
use Livewire\Volt\Volt;
-Route::get('/', function () {
- return view('pages.home');
-})->name('home');
+Volt::route('/', 'pages.home')->name('home');
Volt::route('/booking', 'pages.booking')->name('booking');
Volt::route('/booking/success', 'pages.booking-success')->name('booking.success');
diff --git a/tests/Feature/Public/HomePageTest.php b/tests/Feature/Public/HomePageTest.php
index ec1c851..9e4b7fe 100644
--- a/tests/Feature/Public/HomePageTest.php
+++ b/tests/Feature/Public/HomePageTest.php
@@ -1,5 +1,7 @@
get('/')
->assertOk();
@@ -369,3 +371,188 @@ test('home page displays social innovation value in Arabic', function () {
->assertOk()
->assertSee('الابتكار الاجتماعي');
});
+
+// Latest Posts Section Tests
+
+test('home page does not display posts section when no published posts exist', function () {
+ // No posts created
+ $this->get('/')
+ ->assertOk()
+ ->assertDontSee('id="posts"', false);
+});
+
+test('home page displays posts section when published posts exist', function () {
+ Post::factory()->published()->count(3)->create();
+
+ $this->get('/')
+ ->assertOk()
+ ->assertSee('id="posts"', false);
+});
+
+test('home page displays posts section title in English', function () {
+ Post::factory()->published()->create();
+
+ $this->withSession(['locale' => 'en'])
+ ->get('/')
+ ->assertOk()
+ ->assertSee('Latest Articles');
+});
+
+test('home page displays posts section title in Arabic', function () {
+ Post::factory()->published()->create();
+
+ $this->withSession(['locale' => 'ar'])
+ ->get('/')
+ ->assertOk()
+ ->assertSee('أحدث المقالات');
+});
+
+test('home page displays maximum 3 latest posts', function () {
+ // Create 5 published posts
+ Post::factory()->published()->count(5)->create();
+
+ $response = $this->get('/');
+ $response->assertOk();
+
+ // The section should exist
+ $response->assertSee('id="posts"', false);
+
+ // Count the number of post cards (articles with specific class)
+ $content = $response->getContent();
+ $postCardCount = substr_count($content, 'class="bg-card p-6 rounded-lg shadow-card hover:shadow-card-hover transition-shadow"');
+ expect($postCardCount)->toBe(3);
+});
+
+test('home page displays post titles', function () {
+ $post = Post::factory()->published()->create([
+ 'title' => ['en' => 'Test English Title', 'ar' => 'عنوان اختبار'],
+ ]);
+
+ $this->withSession(['locale' => 'en'])
+ ->get('/')
+ ->assertOk()
+ ->assertSee('Test English Title');
+});
+
+test('home page displays post titles in Arabic', function () {
+ $post = Post::factory()->published()->create([
+ 'title' => ['en' => 'Test English Title', 'ar' => 'عنوان اختبار عربي'],
+ ]);
+
+ $this->withSession(['locale' => 'ar'])
+ ->get('/')
+ ->assertOk()
+ ->assertSee('عنوان اختبار عربي');
+});
+
+test('home page displays post excerpt', function () {
+ $post = Post::factory()->published()->create([
+ 'body' => ['en' => 'This is a test body content for the post that should be truncated.', 'ar' => 'هذا محتوى اختبار'],
+ ]);
+
+ $this->withSession(['locale' => 'en'])
+ ->get('/')
+ ->assertOk()
+ ->assertSee('This is a test body content');
+});
+
+test('home page displays read more link in English', function () {
+ Post::factory()->published()->create();
+
+ $this->withSession(['locale' => 'en'])
+ ->get('/')
+ ->assertOk()
+ ->assertSee('Read More');
+});
+
+test('home page displays read more link in Arabic', function () {
+ Post::factory()->published()->create();
+
+ $this->withSession(['locale' => 'ar'])
+ ->get('/')
+ ->assertOk()
+ ->assertSee('اقرأ المزيد');
+});
+
+test('home page displays view all posts link in English', function () {
+ Post::factory()->published()->create();
+
+ $this->withSession(['locale' => 'en'])
+ ->get('/')
+ ->assertOk()
+ ->assertSee('View All Articles');
+});
+
+test('home page displays view all posts link in Arabic', function () {
+ Post::factory()->published()->create();
+
+ $this->withSession(['locale' => 'ar'])
+ ->get('/')
+ ->assertOk()
+ ->assertSee('عرض جميع المقالات');
+});
+
+test('home page view all posts links to posts index', function () {
+ Post::factory()->published()->create();
+
+ $this->get('/')
+ ->assertOk()
+ ->assertSee('href="'.route('posts.index').'"', false);
+});
+
+test('home page post title links to post show page', function () {
+ $post = Post::factory()->published()->create();
+
+ $this->get('/')
+ ->assertOk()
+ ->assertSee('href="'.route('posts.show', $post).'"', false);
+});
+
+test('home page only shows published posts not drafts', function () {
+ $publishedPost = Post::factory()->published()->create([
+ 'title' => ['en' => 'Published Post Title', 'ar' => 'منشور'],
+ ]);
+
+ $draftPost = Post::factory()->draft()->create([
+ 'title' => ['en' => 'Draft Post Title', 'ar' => 'مسودة'],
+ ]);
+
+ $this->withSession(['locale' => 'en'])
+ ->get('/')
+ ->assertOk()
+ ->assertSee('Published Post Title')
+ ->assertDontSee('Draft Post Title');
+});
+
+test('home page displays posts in order of latest published first', function () {
+ $oldPost = Post::factory()->published()->create([
+ 'title' => ['en' => 'Old Post', 'ar' => 'قديم'],
+ 'published_at' => now()->subDays(10),
+ ]);
+
+ $newPost = Post::factory()->published()->create([
+ 'title' => ['en' => 'New Post', 'ar' => 'جديد'],
+ 'published_at' => now()->subDay(),
+ ]);
+
+ $response = $this->withSession(['locale' => 'en'])->get('/');
+ $response->assertOk();
+
+ $content = $response->getContent();
+ $newPostPosition = strpos($content, 'New Post');
+ $oldPostPosition = strpos($content, 'Old Post');
+
+ // New post should appear before old post
+ expect($newPostPosition)->toBeLessThan($oldPostPosition);
+});
+
+test('home page displays post publication date', function () {
+ $post = Post::factory()->published()->create([
+ 'published_at' => now()->setDate(2026, 1, 15),
+ ]);
+
+ $this->withSession(['locale' => 'en'])
+ ->get('/')
+ ->assertOk()
+ ->assertSee('15 January 2026');
+});