<?php

namespace Tests\Feature;

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

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

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

        $this->assertStringContainsString('BMPA成功', $html);
        $this->assertStringContainsString('/admin/platform-orders?bmpa_success_only=1', $html);
    }

    public function test_platform_orders_filters_should_render_bmpa_success_only_checkbox(): void
    {
        $this->loginAsPlatformAdmin();

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

        $this->assertStringContainsString('name="bmpa_success_only"', $html);
        $this->assertStringContainsString('只看批量标记支付成功', $html);
    }
}
