<?php

namespace Tests\Feature;

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

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

        $this->get('/admin/plans')
            ->assertOk()
            ->assertSee('已发布套餐')
            ->assertSee('未发布套餐')
            ->assertSee('published=published', false)
            ->assertSee('published=unpublished', false)
            // 口径：页面大量 href 使用 `{!! !!}`，必须确保 back 不会被嵌套回传（防 URL 膨胀/绕过）
            ->assertDontSee('back=%2Fadmin%2Fplans%3F', false)
            ->assertDontSee('back=/admin/plans?', false);
    }
}
