TenantAtlas/apps/platform/tests/Unit/Filament/PanelThemeAssetTest.php
ahmido 53e799fea7 Spec 185: workspace recovery posture visibility (#216)
## Summary
- add Spec 185 workspace recovery posture visibility artifacts under `specs/185-workspace-recovery-posture-visibility`
- promote tenant backup health and recovery evidence onto the workspace overview with separate metrics, attention ordering, calmness coverage, and tenant-dashboard drill-throughs
- batch visible-tenant backup/recovery derivation to keep the workspace overview query-bounded
- align follow-up fixes from the authoritative suite rerun, including dashboard truth-alignment fixtures, canonical backup schedule tenant context, guard-path cleanup, smoke-fixture credential removal, and robust theme asset manifest handling

## Testing
- `cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent`
- `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Unit/Filament/PanelThemeAssetTest.php tests/Feature/Guards/DerivedStateConsumerAdoptionGuardTest.php`
- focused regression pack for the previously failing cases passed
- full suite JUnit run passed: `3401` tests, `18849` assertions, `0` failures, `0` errors, `8` skips

## Notes
- no new schema or persisted workspace recovery model
- no provider-registration changes; Filament/Livewire stack remains on Filament v5 and Livewire v4
- no new destructive actions or global search changes

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #216
2026-04-09 12:57:19 +00:00

80 lines
2.5 KiB
PHP

<?php
use App\Support\Filament\PanelThemeAsset;
use Illuminate\Support\Facades\File;
beforeEach(function (): void {
$this->originalPublicPath = public_path();
$this->temporaryPublicPath = null;
});
afterEach(function (): void {
app()->usePublicPath($this->originalPublicPath);
if (is_string($this->temporaryPublicPath) && File::isDirectory($this->temporaryPublicPath)) {
File::deleteDirectory($this->temporaryPublicPath);
}
});
function useTemporaryPublicPath(): string
{
$path = sys_get_temp_dir().'/panel-theme-asset-'.bin2hex(random_bytes(8));
File::ensureDirectoryExists($path);
app()->usePublicPath($path);
test()->temporaryPublicPath = $path;
return $path;
}
it('returns null when no build manifest or hot file exists', function (): void {
useTemporaryPublicPath();
expect(PanelThemeAsset::resolve('resources/css/filament/admin/theme.css'))->toBeNull();
});
it('resolves compiled theme assets from the build manifest', function (): void {
$publicPath = useTemporaryPublicPath();
File::ensureDirectoryExists($publicPath.'/build');
File::put(
$publicPath.'/build/manifest.json',
json_encode([
'resources/css/filament/admin/theme.css' => [
'file' => 'assets/theme-test.css',
],
], JSON_THROW_ON_ERROR),
);
expect(PanelThemeAsset::resolve('resources/css/filament/admin/theme.css'))
->toEndWith('/build/assets/theme-test.css');
});
it('ignores the Vite hot file during tests and still resolves the built manifest asset', function (): void {
$publicPath = useTemporaryPublicPath();
File::ensureDirectoryExists($publicPath.'/build');
File::put($publicPath.'/hot', 'http://localhost:5173');
File::put(
$publicPath.'/build/manifest.json',
json_encode([
'resources/css/filament/admin/theme.css' => [
'file' => 'assets/theme-test.css',
],
], JSON_THROW_ON_ERROR),
);
expect(PanelThemeAsset::resolve('resources/css/filament/admin/theme.css'))
->toEndWith('/build/assets/theme-test.css')
->not->toContain(':5173');
});
it('returns null when the build manifest contains invalid json', function (): void {
$publicPath = useTemporaryPublicPath();
File::ensureDirectoryExists($publicPath.'/build');
File::put($publicPath.'/build/manifest.json', '{invalid-json');
expect(PanelThemeAsset::resolve('resources/css/filament/admin/theme.css'))->toBeNull();
});