<?php

namespace Tests\Feature;

use App\Models\Merchant;
use App\Models\Plan;
use App\Models\PlatformOrder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

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

        $merchant = Merchant::query()->firstOrFail();
        $plan = Plan::query()->create([
            'code' => 'receipt_none_tools_hint_plan',
            'name' => '已付无回执工具区提示测试套餐',
            'billing_cycle' => 'monthly',
            'price' => 10,
            'list_price' => 10,
            'status' => 'active',
            'sort' => 10,
            'published_at' => now(),
        ]);

        PlatformOrder::query()->create([
            'merchant_id' => $merchant->id,
            'plan_id' => $plan->id,
            'order_no' => 'PO_RCPT_NONE_TOOLS_HINT_0001',
            'order_type' => 'renewal',
            'status' => 'activated',
            'payment_status' => 'paid',
            'plan_name' => $plan->name,
            'billing_cycle' => $plan->billing_cycle,
            'period_months' => 1,
            'quantity' => 1,
            'payable_amount' => 10,
            'paid_amount' => 10,
            'placed_at' => now(),
            'paid_at' => now(),
            'activated_at' => now(),
            // 无 payment_summary/payment_receipts，且当前治理语义收口为“已付无回执”集合
            'meta' => [],
        ]);

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

        $res->assertSee('已付无回执提示', false);
        $res->assertSee('当前集合为「已付无回执」且已勾选「只看可同步」', false);
        $res->assertSee('切到有回执集合', false);
        $res->assertSee('取消只看可同步（先治理）', false);
    }
}
