<?php

namespace Tests\Feature;

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

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

        $res = $this->get('/admin/platform-orders?batch_activation_run_id=BAS_BADGE_0001');
        $res->assertOk();

        $res->assertSee('当前 BAS 批次筛选');
        $res->assertSee('BAS_BADGE_0001');
        $res->assertSee('清除 BAS 批次筛选');

        // 快捷入口应包含“本批次成功”（sync_status=synced）
        $res->assertSee('本批次成功');
        $res->assertSee('sync_status=synced', false);

        $res->assertSee('/admin/platform-orders?batch_activation_run_id=', false);
    }
}
