<?php

namespace Tests\Feature;

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

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

        // 模拟“带 back 进入仪表盘”的场景；仪表盘内部入口应仍返回 /admin（selfWithoutBack），而不是沿用 incoming back。
        $res = $this->get('/admin?back=/admin/platform-orders');
        $res->assertOk();

        // 断言：工作台入口链接应带 back=%2Fadmin，而不是 back=%2Fadmin%2Fplatform-orders
        $res->assertSee('back=%2Fadmin', false);
        $res->assertDontSee('back=%2Fadmin%2Fplatform-orders', false);
    }
}
