<?php

namespace Tests\Feature;

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

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

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

        // 结构护栏：最近平台订单 table 必须可被稳定选择
        $res->assertSee('data-role="recent-platform-orders-table"', false);

        $css = (string) file_get_contents(public_path('css/admin-components.css'));

        // CSS 护栏：必须启用 table-layout:fixed，避免长内容把列宽撑破导致横向溢出。
        $this->assertStringContainsString('[data-role="recent-platform-orders-table"]{', $css);
        $this->assertStringContainsString('table-layout:fixed', $css);
    }
}
