withSession(['locale' => $locale])->get('/')->assertOk()->getContent(); } test('home renders the seven sections in order in both languages', function () { foreach (['ar', 'en'] as $locale) { $html = homeHtml($locale); $positions = array_map(fn ($id) => strpos($html, 'id="'.$id.'"'), ['top', 'founder', 'services', 'mission', 'values', 'posts']); $bandPos = strpos($html, 'class="band on-dark"'); foreach ($positions as $p) { expect($p)->not->toBeFalse(); } $sorted = $positions; sort($sorted); expect($positions)->toBe($sorted); expect($bandPos)->toBeGreaterThan($positions[0])->toBeLessThan($positions[1]); } }); test('home copy comes from the site and home keys', function () { $ar = homeHtml('ar'); expect($ar)->toContain(__('site.hero_title_em', [], 'ar'))->toContain(__('site.vision_title', [], 'ar')) ->toContain(__('home.services_subtitle', [], 'ar')); $en = homeHtml('en'); expect($en)->toContain('daily practice')->toContain('Woven from the fabric of society')->toContain('Article 04'); }); test('home has one h1 and every image has alt text', function () { foreach (['ar', 'en'] as $locale) { $html = homeHtml($locale); expect(substr_count($html, 'toBe(1); preg_match_all('/]*>/', $html, $m); foreach ($m[0] as $img) { expect($img)->toMatch('/\balt="[^"]+"/'); } } }); test('site photographs exist as jpegs', function () { foreach (['olive-tree', 'embroidery-hoop', 'olives', 'hills'] as $name) { $path = public_path("images/site/$name.jpg"); expect(file_exists($path))->toBeTrue(); expect(bin2hex(substr(file_get_contents($path), 0, 3)))->toBe('ffd8ff'); } }); test('hero holds the balance and the booking placeholder anchors exist as links', function () { $html = homeHtml('ar'); expect($html)->toContain('data-balance="hero"')->toContain('class="frame"')->toContain('data-balance="static"'); expect(substr_count($html, 'class="row"'))->toBe(4); expect(substr_count($html, 'href="#book"'))->toBeGreaterThanOrEqual(5); expect($html)->toContain(__('home.service_consultation_items', [], 'ar')[0]); }); test('latest posts render as text-only cards, or the empty message', function () { $empty = homeHtml('en'); expect($empty)->toContain(__('home.posts_empty', [], 'en'))->not->toContain('class="posts"'); $posts = Post::factory()->published()->count(3)->create(); $html = homeHtml('en'); expect($html)->toContain('class="posts"'); expect(substr_count($html, 'class="post"'))->toBe(3); expect($html)->toContain(route('posts.show', $posts->first()))->toContain(__('home.read_more', [], 'en')); preg_match('~
(.*?)~s', $html, $block); expect($block[1])->not->toContain('not->toContain('Unsplash'); }); test('site lang keys exist in both languages for the home page', function () { $keys = ['hero_eyebrow', 'hero_title_a', 'hero_title_em', 'hero_title_b', 'trust_1_title', 'trust_3_text', 'alt_olive_tree', 'balance_label', 'frame_caption', 'frame_tag', 'pillars_label', 'pillar_advocacy_text', 'art_founder', 'founder_role', 'founder_quote', 'founder_cta', 'art_services', 'services_lede', 'art_vision', 'vision_title', 'vision_text', 'alt_hoop', 'card_institution_label', 'card_diaspora_text', 'alt_olives', 'alt_hills', 'art_values', 'art_articles']; foreach (['ar', 'en'] as $locale) { $table = require base_path("lang/$locale/site.php"); foreach ($keys as $k) { expect($table)->toHaveKey($k); } } expect(require base_path('lang/en/site.php'))->toHaveKey('hero_title_a', 'Justice is a '); });