<?php

namespace Tests\Feature;

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

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

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

        $res->assertSee('name="lead_id"', false);
        $res->assertSee('线索ID', false);
    }

    public function test_index_should_render_lead_context_badge_when_filtered(): void
    {
        $this->loginAsPlatformAdmin();

        $res = $this->get('/admin/platform-orders?lead_id=12');
        $res->assertOk();

        $res->assertSee('当前线索：#12', false);
    }
}
