<?php

namespace Tests\Feature;

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

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

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

        // 核心列：必须在精简视图保持可见（不应加 col-optional）
        $res->assertSee('<th>订单号</th>', false);
        $res->assertSee('<th>订阅号</th>', false);
        $res->assertSee('<th>订阅到期</th>', false);
        $res->assertSee('<th>同步状态</th>', false);
        $res->assertSee('<th>操作</th>', false);

        // 可选列：精简视图隐藏（通过 col-optional 统一控制）
        $res->assertSee('<th class="col-optional">订单类型</th>', false);
        $res->assertSee('<th class="col-optional">同步时间</th>', false);
        $res->assertSee('<th class="col-optional">失败原因</th>', false);
        $res->assertSee('<th class="col-optional">回执总额</th>', false);
        $res->assertSee('<th class="col-optional">对账差额</th>', false);
        $res->assertSee('<th class="col-optional">退款总额</th>', false);
    }
}
