<?php

namespace Tests\Feature;

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

class AdminPlatformOrderIndexFilterFormKeepsSafeBackTest 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-leads?status=new&keyword=demo';

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

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