<?php

namespace Tests\Feature;

use Tests\TestCase;

class AdminJsDashboardMiniChartsShouldReuseTableLinksSelectorsTest extends TestCase
{
    public function test_admin_js_dashboard_mini_charts_should_reuse_table_links_selectors(): void
    {
        $js = (string) file_get_contents(public_path('js/admin.js'));

        // 趋势：复用日期表格链接
        $this->assertStringContainsString('[data-role="platform-order-trend-7d"] a.link', $js);

        // 排行：复用站点表格链接（按 merchant_id 提取）
        $this->assertStringContainsString('[data-role="merchant-revenue-rank-7d"] a.link[href*="merchant_id="]', $js);

        // 占比：复用套餐表格链接（按 plan_id 提取）
        $this->assertStringContainsString('[data-role="plan-order-share-top5"] a.link[href*="plan_id="]', $js);

        // 渐进增强：可点击则 <a>
        $this->assertStringContainsString("document.createElement(href ? 'a' : 'div')", $js);
    }
}
