60 lines
2.2 KiB
PHP
60 lines
2.2 KiB
PHP
<?php
|
|
|
|
use App\Livewire\Dashboard\Index as DashboardIndex;
|
|
use App\Livewire\Notifications\Index as NotificationsIndex;
|
|
use App\Livewire\PhotoHelp\Index as PhotoHelpIndex;
|
|
use App\Livewire\Progress\Index as ProgressIndex;
|
|
use App\Livewire\Rewards\Index as RewardsIndex;
|
|
use App\Livewire\Settings\Index as SettingsIndex;
|
|
use App\Livewire\Subjects\Index as SubjectsIndex;
|
|
use App\Livewire\Tasks\Index as TasksIndex;
|
|
use Livewire\Attributes\Lazy;
|
|
|
|
/**
|
|
* Verifies all main Livewire pages declare #[Lazy] + a placeholder() that
|
|
* returns a server-rendered skeleton. The skeleton is what users see during
|
|
* page hydration — prevents blank flash.
|
|
*/
|
|
|
|
$pages = [
|
|
DashboardIndex::class,
|
|
SubjectsIndex::class,
|
|
TasksIndex::class,
|
|
PhotoHelpIndex::class,
|
|
RewardsIndex::class,
|
|
ProgressIndex::class,
|
|
NotificationsIndex::class,
|
|
SettingsIndex::class,
|
|
];
|
|
|
|
it('skeleton page component file exists', function () {
|
|
expect(file_exists(base_path('resources/views/components/skeleton/page.blade.php')))->toBeTrue();
|
|
});
|
|
|
|
it('skeleton template has animate-pulse + data-testid="page-skeleton"', function () {
|
|
$tpl = file_get_contents(base_path('resources/views/components/skeleton/page.blade.php'));
|
|
expect($tpl)->toContain('animate-pulse');
|
|
expect($tpl)->toContain('data-testid="page-skeleton"');
|
|
expect($tpl)->toContain('bg-line');
|
|
});
|
|
|
|
foreach ($pages as $pageClass) {
|
|
it("{$pageClass} declares #[Lazy] attribute", function () use ($pageClass) {
|
|
$ref = new ReflectionClass($pageClass);
|
|
$attrs = $ref->getAttributes(Lazy::class);
|
|
expect($attrs)->not->toBeEmpty("Class {$pageClass} must have #[Lazy] attribute");
|
|
});
|
|
|
|
it("{$pageClass} has placeholder() static method returning skeleton view", function () use ($pageClass) {
|
|
$ref = new ReflectionClass($pageClass);
|
|
expect($ref->hasMethod('placeholder'))->toBeTrue("Class {$pageClass} must define placeholder()");
|
|
|
|
$method = $ref->getMethod('placeholder');
|
|
expect($method->isStatic())->toBeTrue("{$pageClass}::placeholder() must be static");
|
|
|
|
$view = $pageClass::placeholder([]);
|
|
expect($view)->toBeInstanceOf(Illuminate\Contracts\View\View::class);
|
|
expect($view->getName())->toBe('components.skeleton.page');
|
|
});
|
|
}
|