<?php

namespace Tests\Feature;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class AdminComponentsCssPageHeaderShouldUseThemeTokensTest 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_components_css_page_header_should_use_theme_tokens(): void
    {
        $this->loginAsPlatformAdmin();

        $css = file_get_contents(public_path('css/admin-components.css'));
        $this->assertIsString($css);

        // PageHeader 组件必须走主题令牌，避免后续统一换肤/统一基线时需要全局搜替换。
        $this->assertStringContainsString('.page-header{', $css);
        $this->assertStringContainsString('border:1px solid var(--adm-border-color, #e5e7eb)', $css);
        $this->assertStringContainsString('background:var(--adm-bg-container, #ffffff)', $css);
        $this->assertStringContainsString('border-radius:var(--adm-radius, 12px)', $css);

        // 标题/副标题要使用文本 token。
        $this->assertStringContainsString('color:var(--adm-text, #0f172a)', $css);
        $this->assertStringContainsString('color:var(--adm-text-secondary, #64748b)', $css);
    }
}
