<?php

namespace Tests\Feature;

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

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

        // status=pending&payment_status=unpaid 是 BMPA 的基本口径；但叠加“同步失败”治理筛选应禁用（与后端阻断一致）。
        $res = $this->get('/admin/platform-orders?status=pending&payment_status=unpaid&fail_only=1');
        $res->assertOk();

        $html = (string) $res->getContent();

        $this->assertStringContainsString('批量标记支付并生效（含订阅同步）（当前筛选范围）', $html);
        $this->assertStringContainsString('data-role="batch-bmpa-blocked-hint"', $html);
        $this->assertStringContainsString('同步', $html);

        // 按钮 disabled（宽松断言）
        $this->assertTrue(str_contains($html, 'type="submit" disabled') || str_contains($html, 'disabled="disabled"'));
    }
}
