<?php

namespace Tests\Feature;

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

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

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

        $res->assertSee('套餐订单占比', false);
        $res->assertSee('Top5', false);
        $res->assertSee('查看套餐', false);
        $res->assertSee('data-role="plan-order-share-top5-chart"', false);
        $res->assertSee('data-role="plan-order-share-top5-meta"', false);
        $res->assertSee('Top1占比', false);

        // 有数据时至少应包含百分号展示
        $res->assertSee('%', false);
    }
}
