test(admin-ui): guard against hardcoded neutral rgba in admin css

This commit is contained in:
萝卜
2026-03-16 02:26:50 +08:00
parent 9c6756e991
commit e12ac7ef50

View File

@@ -0,0 +1,40 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminCssShouldNotHardcodeNeutralRgbaValuesTest extends TestCase
{
use RefreshDatabase;
protected function loginAsPlatformAdmin(): void
{
$this->seed();
$this->post('/admin/login', [
'email' => 'platform.admin@demo.local',
'password' => 'Platform@123456',
])->assertRedirect('/admin');
}
public function test_admin_css_should_not_hardcode_neutral_rgba_values(): void
{
$this->loginAsPlatformAdmin();
$components = file_get_contents(public_path('css/admin-components.css'));
$base = file_get_contents(public_path('css/admin-base.css'));
$this->assertIsString($components);
$this->assertIsString($base);
// 中性色15,23,42也应尽量通过 token/var() 管理,避免散落硬编码导致“质感”不可统一。
// 说明:允许出现在 var() fallback 内(例如 var(--adm-shadow-popover, 0 12px 30px rgba(...)))。
$this->assertStringNotContainsString('background:rgba(15, 23, 42', $components);
$this->assertStringNotContainsString('background:rgba(15, 23, 42', $base);
$this->assertStringNotContainsString('box-shadow:0 12px 30px rgba(15, 23, 42', $components);
$this->assertStringNotContainsString('box-shadow:0 12px 30px rgba(15, 23, 42', $base);
}
}