fix(admin-dashboard): billing workbench links use selfWithoutBack for back param
This commit is contained in:
@@ -5,24 +5,22 @@
|
|||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
@php
|
@php
|
||||||
$incomingBack = (string) request()->query('back', '');
|
|
||||||
$safeBackForLinks = \App\Support\BackUrl::sanitizeForLinks($incomingBack);
|
|
||||||
|
|
||||||
// 用于构建“从仪表盘跳到其它治理页后可返回仪表盘”的 back
|
// 用于构建“从仪表盘跳到其它治理页后可返回仪表盘”的 back
|
||||||
$selfWithoutBack = \App\Support\BackUrl::selfWithoutBack();
|
$selfWithoutBack = \App\Support\BackUrl::selfWithoutBack();
|
||||||
|
|
||||||
|
// 重要:从仪表盘跳转到治理页时,应默认返回“仪表盘”本身(而不是沿用进入仪表盘时的 back)。
|
||||||
$billingEntryLinks = [
|
$billingEntryLinks = [
|
||||||
'platform_orders' => \App\Support\BackUrl::withBack('/admin/platform-orders', $safeBackForLinks),
|
'platform_orders' => \App\Support\BackUrl::withBack('/admin/platform-orders', $selfWithoutBack),
|
||||||
'site_subscriptions' => \App\Support\BackUrl::withBack('/admin/site-subscriptions', $safeBackForLinks),
|
'site_subscriptions' => \App\Support\BackUrl::withBack('/admin/site-subscriptions', $selfWithoutBack),
|
||||||
'plans' => \App\Support\BackUrl::withBack('/admin/plans', $safeBackForLinks),
|
'plans' => \App\Support\BackUrl::withBack('/admin/plans', $selfWithoutBack),
|
||||||
];
|
];
|
||||||
|
|
||||||
$platformOrdersQuickLinks = [
|
$platformOrdersQuickLinks = [
|
||||||
'unpaid_pending' => \App\Support\BackUrl::withBack('/admin/platform-orders?payment_status=unpaid&status=pending', $safeBackForLinks),
|
'unpaid_pending' => \App\Support\BackUrl::withBack('/admin/platform-orders?payment_status=unpaid&status=pending', $selfWithoutBack),
|
||||||
// 待生效:paid + pending,并显式锁定 sync_status=unsynced(排除同步失败等异常单)
|
// 待生效:paid + pending,并显式锁定 sync_status=unsynced(排除同步失败等异常单)
|
||||||
'paid_pending' => \App\Support\BackUrl::withBack('/admin/platform-orders?payment_status=paid&status=pending&sync_status=unsynced', $safeBackForLinks),
|
'paid_pending' => \App\Support\BackUrl::withBack('/admin/platform-orders?payment_status=paid&status=pending&sync_status=unsynced', $selfWithoutBack),
|
||||||
'syncable_only' => \App\Support\BackUrl::withBack('/admin/platform-orders?syncable_only=1', $safeBackForLinks),
|
'syncable_only' => \App\Support\BackUrl::withBack('/admin/platform-orders?syncable_only=1', $selfWithoutBack),
|
||||||
'sync_failed' => \App\Support\BackUrl::withBack('/admin/platform-orders?sync_status=failed', $safeBackForLinks),
|
'sync_failed' => \App\Support\BackUrl::withBack('/admin/platform-orders?sync_status=failed', $selfWithoutBack),
|
||||||
];
|
];
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user