<?php

namespace Tests\Feature;

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

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

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

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

        $this->assertStringContainsString('data-role="po-quickfilter-receipt-has"', $html);
        $this->assertStringContainsString('data-role="po-quickfilter-paid-no-receipt"', $html);
        $this->assertStringNotContainsString('data-role="po-quickfilter-receipt-none"', $html);
        $this->assertStringContainsString('data-role="po-quickfilter-refund-has"', $html);
        $this->assertStringContainsString('data-role="po-quickfilter-refund-none"', $html);

        // 也钉一下关键 query 语义
        $this->assertStringContainsString('receipt_status=has', $html);
        $this->assertStringContainsString('payment_status=paid', $html);
        $this->assertStringContainsString('receipt_status=none', $html);
        $this->assertStringContainsString('refund_status=has', $html);
        $this->assertStringContainsString('refund_status=none', $html);
    }
}
