<?php

namespace Tests\Feature;

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

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

        $url = '/admin/platform-orders?' . Arr::query([
            'lead_id' => 12,
        ]);

        $res = $this->get($url);
        $res->assertOk();

        $res->assertSee('线索治理入口：', false);

        $unpaidUrl = '/admin/platform-orders?' . Arr::query([
            'lead_id' => 12,
            'payment_status' => 'unpaid',
        ]);

        $paidPendingUrl = '/admin/platform-orders?' . Arr::query([
            'lead_id' => 12,
            'payment_status' => 'paid',
            'status' => 'pending',
        ]);

        $res->assertSee($unpaidUrl, false);
        $res->assertSee($paidPendingUrl, false);
    }
}
