<?php

namespace Tests\Feature;

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

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

        $res = $this->get('/admin/platform-orders?syncable_only=1&refund_status=has');
        $res->assertOk();

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

        $this->assertStringContainsString('批量同步订阅（当前筛选范围）', $html);
        $this->assertStringContainsString('data-role="batch-activate-subscriptions-blocked-hint"', $html);
        $this->assertStringContainsString('有退款', $html);

        $this->assertTrue(str_contains($html, 'type="submit" disabled') || str_contains($html, 'disabled="disabled"'));
    }
}
