Files
saasshop/tests/Feature/AdminCssShouldNotHardcodePrimaryRgbaValuesTest.php

41 lines
1.4 KiB
PHP
Raw 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 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);
}
}