<?php

namespace Tests\Feature;

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

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

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

        $res->assertSee('排行（近7天站点收入 Top5）', false);
        $res->assertSee('data-role="merchant-revenue-rank-7d-chart"', false);
        $res->assertSee('data-role="merchant-revenue-rank-7d-meta"', false);
        $res->assertSee('data-role="merchant-revenue-rank-7d"', false);

        // 链接应携带 back（保持仪表盘治理链路一致性）
        $res->assertSee('back=%2Fadmin', false);
        $res->assertDontSee('&amp;back=', false);
    }
}
