<?php

namespace Tests\Feature;

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

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

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

        // 链接应携带 back 回到仪表盘，并且 & 不应被 escape
        $res->assertSee('href="/admin/platform-orders?renewal_missing_subscription=1&back=%2Fadmin"', false);
        $res->assertDontSee('&amp;back=', false);

        $res->assertSee('续费缺订阅', false);
    }
}
