Some checks failed
Main Confidence / confidence (push) Failing after 44s
## Summary - enforce shared operation run link generation across admin and system surfaces - add guard coverage to block new raw operation route bypasses outside explicit exceptions - harden Filament theme asset resolution so stale or wrong-stack hot files fall back to built assets ## Testing - export PATH="/bin:/usr/bin:/usr/local/bin:$PATH" && cd apps/platform && ./vendor/bin/sail bin pint --dirty --format agent - export PATH="/bin:/usr/bin:/usr/local/bin:$PATH" && cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/OpsUx/CanonicalViewRunLinksTest.php tests/Feature/Monitoring/OperationsDashboardDrillthroughTest.php tests/Feature/Filament/RecentOperationsSummaryWidgetTest.php tests/Feature/Filament/InventoryCoverageRunContinuityTest.php tests/Feature/ReviewPack/ReviewPackResourceTest.php tests/Feature/144/CanonicalOperationViewerDeepLinkTrustTest.php tests/Feature/078/RelatedLinksOnDetailTest.php tests/Feature/RunAuthorizationTenantIsolationTest.php tests/Feature/System/Spec195/SystemDirectoryResidualSurfaceTest.php tests/Feature/System/Spec113/AuthorizationSemanticsTest.php tests/Feature/Guards/OperationRunLinkContractGuardTest.php tests/Unit/Filament/PanelThemeAssetTest.php Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #268
103 lines
3.3 KiB
PHP
103 lines
3.3 KiB
PHP
<?php
|
|
|
|
use App\Support\Filament\PanelThemeAsset;
|
|
use Illuminate\Support\Facades\File;
|
|
|
|
beforeEach(function (): void {
|
|
$this->originalPublicPath = public_path();
|
|
$this->originalEnvironment = app()->environment();
|
|
$this->temporaryPublicPath = null;
|
|
});
|
|
|
|
afterEach(function (): void {
|
|
app()->usePublicPath($this->originalPublicPath);
|
|
app()->instance('env', $this->originalEnvironment);
|
|
|
|
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('falls back to the built manifest asset when the Vite hot server is unreachable', function (): void {
|
|
$publicPath = useTemporaryPublicPath();
|
|
|
|
app()->instance('env', 'local');
|
|
|
|
File::ensureDirectoryExists($publicPath.'/build');
|
|
File::put($publicPath.'/hot', 'http://127.0.0.1:1');
|
|
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(':1');
|
|
});
|
|
|
|
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();
|
|
});
|