diff --git a/tests/Feature/AdminPlanShowTest.php b/tests/Feature/AdminPlanShowTest.php index 3ca7dd0..e097687 100644 --- a/tests/Feature/AdminPlanShowTest.php +++ b/tests/Feature/AdminPlanShowTest.php @@ -240,4 +240,41 @@ class AdminPlanShowTest extends TestCase $res->assertSee($expectedPaidNoReceiptUrl, false); $res->assertDontSee('back=' . $safeBack, false); } + + public function test_plan_show_header_actions_should_use_plan_show_self_back_even_when_safe_back_is_present(): void + { + $this->loginAsPlatformAdmin(); + + $plan = Plan::query()->create([ + 'code' => 'plan_show_header_cta_back_test', + 'name' => '套餐详情顶部动作回链测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 66, + 'list_price' => 88, + 'status' => 'active', + 'sort' => 10, + ]); + + $safeBack = '/admin/plans?' . Arr::query([ + 'status' => 'active', + 'billing_cycle' => 'monthly', + ]); + + $res = $this->get('/admin/plans/' . $plan->id . '?back=' . urlencode($safeBack)); + $res->assertOk(); + + $planShowSelf = '/admin/plans/' . $plan->id; + $expectedEditUrl = '/admin/plans/' . $plan->id . '/edit?' . Arr::query([ + 'back' => $planShowSelf, + ]); + $expectedCreateOrderUrl = '/admin/platform-orders/create?' . Arr::query([ + 'plan_id' => $plan->id, + 'order_type' => 'new_purchase', + 'back' => $planShowSelf, + ]); + + $res->assertSee($expectedEditUrl, false); + $res->assertSee($expectedCreateOrderUrl, false); + $res->assertDontSee('back=' . $safeBack, false); + } }