<?php

namespace Tests\Feature;

use App\Models\Plan;
use App\Models\PlatformLead;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

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

        $plan = Plan::query()->create([
            'code' => 'lead_btn_plan',
            'name' => '线索按钮样式测试套餐',
            'billing_cycle' => 'monthly',
            'price' => 10,
            'list_price' => 10,
            'status' => 'active',
            'sort' => 10,
            'published_at' => now(),
        ]);

        PlatformLead::query()->create([
            'name' => '按钮样式线索',
            'mobile' => '13800000002',
            'email' => 'btn@example.com',
            'company' => '样式公司',
            'source' => 'test',
            'status' => 'new',
            'plan_id' => $plan->id,
            'meta' => ['from' => 'test'],
        ]);

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

        $res->assertSee('class="btn btn-sm"', false);
        $res->assertSee('>创建订单<', false);
    }
}
