Files
saasshop/tests/Feature/AdminCssShouldNotHardcodeNeutralRgbaValuesTest.php

41 lines
1.4 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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);
}
}