Files
libra/tests/Feature/Design/PublicNavFooterTest.php
T
Naser Mansour 8b2c35f76f 24-2: navigation and footer — implemented, QA Review
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-31 18:43:25 +02:00

79 lines
3.1 KiB
PHP

<?php
use App\Models\User;
function siteKeys(): array
{
return ['brand_name', 'brand_sub', 'brand_label', 'nav_main', 'nav_home', 'nav_about', 'nav_services', 'nav_articles',
'nav_booking', 'nav_login', 'nav_book', 'nav_menu', 'lang_switch', 'footer_explore', 'footer_clients',
'footer_contact', 'footer_terms', 'footer_privacy'];
}
test('every nav and footer key exists in both languages', function () {
foreach (['ar', 'en'] as $locale) {
$table = require base_path("lang/$locale/site.php");
foreach (siteKeys() as $key) {
expect($table)->toHaveKey($key);
}
}
});
test('navigation is the sticky site header', function () {
$html = $this->get('/')->assertOk()->getContent();
expect($html)
->toContain('class="nav"')
->toContain('id="site-nav"')
->toContain('class="seal"')
->toContain('class="links"')
->toContain('class="lang"')
->toContain('href="'.route('login').'"')
->toContain('btn btn-gold')
->toContain('class="menu-btn"')
->toContain('mobileMenuOpen');
});
test('about link is current on about, articles on posts', function () {
$about = $this->get('/about')->assertOk()->getContent();
expect($about)->toMatch('~<a[^>]*href="'.preg_quote(route('about'), '~').'"[^>]*aria-current="page"~');
$posts = $this->get('/posts')->assertOk()->getContent();
expect($posts)->toMatch('~<a[^>]*href="'.preg_quote(route('posts.index'), '~').'"[^>]*aria-current="page"~');
});
test('language pill reads EN on Arabic and the Arabic letter on English', function () {
$ar = $this->withSession(['locale' => 'ar'])->get('/')->getContent();
expect($ar)->toContain('href="'.url('/language/en').'"');
$en = $this->withSession(['locale' => 'en'])->get('/')->getContent();
expect($en)->toContain('href="'.url('/language/ar').'"');
});
test('clients and admins see Dashboard and logout instead of login', function () {
$client = $this->actingAs(User::factory()->individual()->create())->get('/')->getContent();
expect($client)->toContain(route('client.dashboard'))->toContain('action="'.route('logout').'"');
auth()->logout();
$admin = $this->actingAs(User::factory()->admin()->create())->get('/')->getContent();
expect($admin)->toContain(route('admin.dashboard'));
});
test('footer has four columns, contact details, legal links and no photo credit', function () {
$html = $this->get('/')->assertOk()->getContent();
expect($html)
->toContain('class="site-footer"')
->toContain('class="foot-band"')
->toContain('tel:+970599353502')
->toContain(route('terms'))
->toContain(route('privacy'))
->toContain('&copy; '.date('Y'))
->not->toContain('Unsplash');
expect(substr_count($html, '<h4'))->toBe(3);
});
test('shared files stay untouched and navigation is only used by the public layout', function () {
$files = shell_exec('grep -rln "x-navigation" '.escapeshellarg(resource_path('views')));
expect(trim($files))->toEndWith('components/layouts/public.blade.php');
});