<?php

namespace Tests\Feature;

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

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

        $runId = 'BMPA_TEST_BADGE_0001';

        $html = $this->get('/admin/platform-orders?batch_bmpa_run_id=' . $runId)
            ->assertOk()
            ->getContent();

        $this->assertStringContainsString('当前 BMPA run_id：<strong>' . $runId . '</strong>', $html);

        // 快捷入口：本批次失败（应带 batch_bmpa_run_id + bmpa_failed_only=1）
        $this->assertStringContainsString('batch_bmpa_run_id=' . $runId, $html);
        $this->assertStringContainsString('bmpa_failed_only=1', $html);

        // 快捷入口：本批次可再次尝试（可BMPA处理）
        $this->assertStringContainsString('bmpa_processable_only=1', $html);

        // 快捷入口：本批次成功
        $this->assertStringContainsString('bmpa_success_only=1', $html);
    }
}
