<?php

namespace Tests\Feature;

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

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

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

        // 护栏：商品列表区域应走统一 List Card 骨架。
        $res->assertSee('list-card', false);
        $res->assertSee('list-card-header', false);
        $res->assertSee('list-card-body', false);
        $res->assertSee('list-card-table', false);

        // 分页统一：数据量可能不足导致 hasPages=false，因此用扫描型护栏断言。
        $blade = file_get_contents(resource_path('views/admin/products/index.blade.php'));
        $this->assertIsString($blade);
        $this->assertStringContainsString("links('pagination.admin')", $blade);
    }
}
