<?php

namespace Tests\Feature;

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

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

        $res = $this->get('/admin/site-subscriptions?attach_order_id=123&attach_back=%2Fadmin%2Fplatform-orders%2F123');
        $res->assertOk();

        $html = (string) $res->getContent();

        // attach_order 模式：filters-card 不应默认 open（减少干扰）
        $this->assertStringContainsString('data-storage-key="admin.site_subscriptions.filters"', $html);

        // 简单但有效：断言该 details 标签不含 open 属性
        $this->assertStringNotContainsString('data-storage-key="admin.site_subscriptions.filters" open', $html);
    }
}
