<?php

namespace Tests\Feature;

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

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

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

        // 护栏：商品分类页应使用统一 Filters Card + List Card 结构，便于全站后台观感一致。
        $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);

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