<?php

namespace Tests\Feature;

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

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

        $leadId = 12;

        $res = $this->get('/admin/platform-orders?' . Arr::query([
            'lead_id' => $leadId,
        ]));
        $res->assertOk();

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

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

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

        $paidNoReceiptUrl = '/admin/platform-orders?' . Arr::query([
            'lead_id' => $leadId,
            'payment_status' => 'paid',
            'receipt_status' => 'none',
        ]);

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

        $syncableUrl = '/admin/platform-orders?' . Arr::query([
            'lead_id' => $leadId,
            'syncable_only' => '1',
        ]);

        $syncFailedUrl = '/admin/platform-orders?' . Arr::query([
            'lead_id' => $leadId,
            'sync_status' => 'failed',
        ]);

        $res->assertSee($unpaidUrl, false);
        $res->assertSee($paidPendingUrl, false);
        $res->assertSee($paidNoReceiptUrl, false);
        $res->assertSee($bmpaUrl, false);
        $res->assertSee($syncableUrl, false);
        $res->assertSee($syncFailedUrl, false);
    }
}
