<?php

namespace Tests\Feature;

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

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

        // 不在 expiry=expired 集合时，blocked hint 的“一键切到已过期集合”应保留当前 ends_from/ends_to（减少重复输入）。
        $res = $this->get('/admin/site-subscriptions?ends_from=2026-03-01&ends_to=2026-03-31');
        $res->assertOk();

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

        $this->assertStringContainsString('data-role="batch-mark-expired-blocked-hint"', $html);
        $this->assertStringContainsString('expiry=expired', $html);
        $this->assertStringContainsString('ends_from=2026-03-01', $html);
        $this->assertStringContainsString('ends_to=2026-03-31', $html);
    }
}
