<?php

namespace Tests\Feature;

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

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

        // 含引号的 back：必须丢弃
        $back = "/admin/platform-leads?keyword=\"on\"";

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

        $res->assertDontSee('name="back"', false);
        $res->assertDontSee('value="' . $back . '"', false);
    }
}
