test(admin-ui): guard against hardcoded primary rgba in admin css
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminCssShouldNotHardcodePrimaryRgbaValuesTest 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_primary_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);
|
||||
|
||||
// 交互色必须走 --adm-primary-* token。
|
||||
// 允许在 var() fallback 中出现 rgba(例如 var(--adm-primary-tint-08, rgba(...)));
|
||||
// 但不允许直接写成 background:rgba(...) 或 border-color:rgba(...)。
|
||||
$this->assertStringNotContainsString('background:rgba(22, 119, 255', $components);
|
||||
$this->assertStringNotContainsString('border-color:rgba(22, 119, 255', $components);
|
||||
$this->assertStringNotContainsString('background:rgba(22, 119, 255', $base);
|
||||
$this->assertStringNotContainsString('box-shadow:0 0 0 3px rgba(22, 119, 255', $base);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user