<?php

namespace Tests\Feature;

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

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

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

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

        // 收款漏斗 mini bars
        $this->assertStringContainsString('data-role="platform-ops-funnel-bars"', $html);
        $this->assertStringContainsString('data-role="ops-funnel-unpaid-pending-bar"', $html);
        $this->assertStringContainsString('data-role="ops-funnel-paid-bar"', $html);
        $this->assertStringContainsString('data-role="ops-funnel-paid-activated-bar"', $html);

        // 待处理治理 Top3 mini bars
        $this->assertStringContainsString('data-role="platform-ops-governance-bars"', $html);
        $this->assertStringContainsString('data-role="ops-govern-bmpa-bar"', $html);
        $this->assertStringContainsString('data-role="ops-govern-syncable-bar"', $html);
        $this->assertStringContainsString('data-role="ops-govern-sync-failed-bar"', $html);
    }
}
