Files
libra/tests/Feature/Design/PublicFoundationTest.php
T
2026-10-31 18:41:12 +02:00

58 lines
2.2 KiB
PHP

<?php
use App\Models\User;
test('public stylesheet exists and every selector is scoped under body.site', function () {
$path = resource_path('css/public.css');
expect(file_exists($path))->toBeTrue();
$lines = preg_grep('/^[^@\/ }].*\{/', file($path, FILE_IGNORE_NEW_LINES));
$unscoped = array_filter($lines, fn ($l) => ! str_contains($l, 'body.site') && ! str_contains($l, 'html:has(body.site)'));
expect($unscoped)->toBe([]);
});
test('public script modules exist', function () {
foreach (['public.js', 'site/reveal.js', 'site/progress.js'] as $f) {
expect(file_exists(resource_path("js/$f")))->toBeTrue();
}
});
test('vite config lists the public entries', function () {
$cfg = file_get_contents(base_path('vite.config.js'));
expect($cfg)->toContain('resources/css/public.css')->toContain('resources/js/public.js');
});
test('home page uses the site foundation', function () {
$html = $this->get('/')->assertOk()->getContent();
expect($html)
->toContain('<body class="site')
->toContain('Markazi+Text')
->toMatch('~build/assets/public-[\w-]+\.css~')
->toMatch('~build/assets/public-[\w-]+\.js~')
->toContain('<div class="site-progress"');
});
test('dashboards do not load the public foundation', function () {
foreach ([[User::factory()->admin()->create(), '/admin/dashboard'], [User::factory()->individual()->create(), '/client/dashboard']] as [$user, $url]) {
$html = $this->actingAs($user)->get($url)->assertOk()->getContent();
expect($html)
->not->toContain('public.css')
->not->toContain('public.js')
->not->toContain('Markazi')
->not->toContain('class="site');
}
});
test('head theme colour is the forest green', function () {
$head = file_get_contents(resource_path('views/partials/head.blade.php'));
expect($head)->toContain('content="#2D3624"')->not->toContain('#4A4A42');
});
test('site lang files carry the progress label', function () {
expect(trans('site.progress_label', [], 'en'))->toBe('Reading progress');
expect(trans('site.progress_label', [], 'ar'))->toBe('تقدّم القراءة');
});