Files
landing-api/tests/Feature/Panel/EveryPanelPageRendersTest.php
Josep Piguillem 3897113313 Initial commit: Pireon Admin — headless admin panel and public API
Laravel 13 + Filament 5 admin panel and REST API for a non-profit developer
collective, backed by the Pireon OAuth identity server. The public site is a
separate, server-rendered application consuming /api/public/v1.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 17:55:27 +02:00

78 lines
2.3 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Feature\Panel;
use Database\Seeders\RolePermissionSeeder;
use Filament\Facades\Filament;
use Filament\Resources\Resource;
use Illuminate\Foundation\Testing\RefreshDatabase;
use PHPUnit\Framework\Attributes\Test;
use Tests\FakesPireon;
use Tests\TestCase;
use Throwable;
/**
* Every screen in the panel opens.
*
* This exists because of how the settings page broke: nothing referenced a
* method that had moved in Filament, nothing failed to compile, and the suite
* stayed green — the page simply threw the first time a human opened it,
* months after it was written. A screen nobody has visited is a screen nobody
* has tested, and there is no cheaper way to visit all of them than this.
*/
class EveryPanelPageRendersTest extends TestCase
{
use FakesPireon, RefreshDatabase;
#[Test]
public function every_resource_listing_opens(): void
{
$this->seed(RolePermissionSeeder::class);
$this->actingAs($this->userWithRoles('super_admin'));
$failures = [];
foreach (Filament::getPanel('admin')->getResources() as $resource) {
/** @var class-string<resource> $resource */
if (! array_key_exists('index', $resource::getPages())) {
continue;
}
$failures = [...$failures, ...$this->visit($resource::getUrl('index'), $resource)];
}
$this->assertSame([], $failures, implode("\n", $failures));
}
#[Test]
public function every_custom_page_opens(): void
{
$this->seed(RolePermissionSeeder::class);
$this->actingAs($this->userWithRoles('super_admin'));
$failures = [];
foreach (Filament::getPanel('admin')->getPages() as $page) {
$failures = [...$failures, ...$this->visit($page::getUrl(), $page)];
}
$this->assertSame([], $failures, implode("\n", $failures));
}
/**
* @return array<int, string>
*/
protected function visit(string $url, string $subject): array
{
try {
$status = $this->withoutExceptionHandling()->get($url)->status();
} catch (Throwable $e) {
return ["{$subject} — {$url}\n ".$e::class.': '.$e->getMessage()];
}
return $status === 200 ? [] : ["{$subject} — {$url} answered {$status}"];
}
}