<?php

namespace Tests\Feature;

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

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

        $res = $this->get('/admin');
        $res->assertOk();

        $html = (string) $res->getContent();

        // PageHeader + KPI row
        $this->assertStringContainsString('data-page="admin.dashboard"', $html);
        $this->assertStringContainsString('class="page-header', $html);
        $this->assertStringContainsString('class="kpi-grid', $html);

        // Analysis 版式占位：
        // - 第一行：趋势 + 排行
        $this->assertStringContainsString('data-role="analysis-skeleton"', $html);
        $this->assertStringContainsString('趋势', $html);
        $this->assertStringContainsString('排行', $html);

        // - 第二行：最近订单 + 占比（占位）
        $this->assertStringContainsString('data-role="analysis-skeleton-row2"', $html);
        $this->assertStringContainsString('最近平台订单', $html);
        $this->assertStringContainsString('占比', $html);
    }
}
