<?php

namespace Tests\Feature;

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

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

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

        $res->assertOk();
        $res->assertSee('治理风险占比');
        $res->assertSee('口径说明');
        $res->assertSee('同步失败=meta.subscription_activation_error.message');
        $res->assertSee('BMPA失败=meta.batch_mark_paid_and_activate_error.message');
        $res->assertSee('已付无回执=已支付但缺 payment_receipts');
        $res->assertSee('对账不一致=回执汇总金额与 paid_amount 不一致');
        $res->assertSee('退款不一致=退款汇总与退款状态不一致');
        $res->assertSee('续费缺订阅=renewal 但 site_subscription_id 为空');
    }
}
