<?php

namespace Tests\Feature;

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

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

        // 页面可访问即可（确保 admin.js 会被加载的整体链路没断）
        $this->get('/admin')->assertOk();

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

        // 护栏：mini rank / mini share 的 name 节点应设置 title（用于 ellipsis 后查看完整名称）
        $this->assertStringContainsString("name.title = mname", $js);
        $this->assertStringContainsString("name.title = pname", $js);

        // 护栏：排行/占比行 title 应包含名称（让 hover 提示更可读）
        $this->assertStringContainsString("'：' + mname + '｜已付 ¥'", $js);
        $this->assertStringContainsString("'：' + pname + '｜'", $js);
    }
}
