<?php

namespace Tests\Feature;

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

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

        $back = '/admin/platform-orders?lead_id=1&status=pending';

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

        // 过滤表单应透传 back，避免“应用筛选”后丢上下文
        $res->assertSee('name="back" value="' . $back . '"', false);
    }
}
