diff --git a/tests/Feature/AdminPlanShowTest.php b/tests/Feature/AdminPlanShowTest.php index ed659fe..59d867f 100644 --- a/tests/Feature/AdminPlanShowTest.php +++ b/tests/Feature/AdminPlanShowTest.php @@ -364,5 +364,47 @@ class AdminPlanShowTest extends TestCase $res->assertDontSee('back=' . $unsafeBack, false); $res->assertDontSee('back%3D', false); } + + public function test_plan_show_should_render_safe_back_but_subscription_governance_links_should_still_use_plan_show_self_back(): void + { + $this->loginAsPlatformAdmin(); + + $plan = Plan::query()->create([ + 'code' => 'plan_show_subscription_governance_safe_back_test', + 'name' => '套餐详情订阅治理入口 safe back 测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 96, + 'list_price' => 126, + 'status' => 'active', + 'sort' => 10, + ]); + + $safeBack = '/admin/plans?' . Arr::query([ + 'status' => 'active', + 'keyword' => '订阅治理', + ]); + + $res = $this->get('/admin/plans/' . $plan->id . '?back=' . urlencode($safeBack)); + $res->assertOk(); + + $res->assertSee('href="' . $safeBack . '"', false); + $res->assertSee('返回上一页(保留上下文)'); + + $planShowSelf = '/admin/plans/' . $plan->id; + + $expectedSubscriptionsUrl = '/admin/site-subscriptions?' . Arr::query([ + 'plan_id' => $plan->id, + 'back' => $planShowSelf, + ]); + $expectedExpiringSubscriptionsUrl = '/admin/site-subscriptions?' . Arr::query([ + 'plan_id' => $plan->id, + 'expiry' => 'expiring_7d', + 'back' => $planShowSelf, + ]); + + $res->assertSee($expectedSubscriptionsUrl, false); + $res->assertSee($expectedExpiringSubscriptionsUrl, false); + $res->assertDontSee('back=' . $safeBack, false); + } }