<?php

namespace Tests\Feature;

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

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

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

        // 护栏：订单监控页的筛选区/列表区需走统一骨架，便于全站后台观感一致。
        $response->assertSee('filters-card', false);
        $response->assertSee('filters-summary', false);
        $response->assertSee('filters-body', false);
        $response->assertSee('filters-grid', false);

        $response->assertSee('list-card', false);
        $response->assertSee('list-card-header', false);
        $response->assertSee('list-card-body', false);
        $response->assertSee('list-card-table', false);

        // 分页统一：此页可能只有 1 页数据（hasPages=false 时不会渲染 adm-pagination）。
        // 因此这里用“扫描型护栏”约束：Blade 必须显式使用 admin pagination view。
        $blade = file_get_contents(resource_path('views/admin/orders/index.blade.php'));
        $this->assertIsString($blade);
        $this->assertStringContainsString("links('pagination.admin')", $blade);
    }
}
