<?php

namespace Tests\Feature;

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

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

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

        $js = (string) file_get_contents(public_path('js/admin.js'));

        // 护栏：趋势 bar 的 tooltip 应包含“单均”口径（更便于运营理解波动）
        $this->assertStringContainsString("'｜单均 ¥'", $js);
        $this->assertStringContainsString('formatMoney(avg)', $js);
    }
}
