From f9c62afaba74a5e5412fade5762afef70d35ebf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Fri, 20 Mar 2026 10:59:15 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E9=BD=90=E5=B9=B3=E5=8F=B0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E8=AF=A6=E6=83=85=E9=A1=B5=E7=BA=BF=E7=B4=A2=E5=9B=9E?= =?UTF-8?q?=E9=93=BE=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...OrderShowSelfBackWhenOuterBackSafeTest.php | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderShowLeadContextLinkShouldUseOrderShowSelfBackWhenOuterBackSafeTest.php diff --git a/tests/Feature/AdminPlatformOrderShowLeadContextLinkShouldUseOrderShowSelfBackWhenOuterBackSafeTest.php b/tests/Feature/AdminPlatformOrderShowLeadContextLinkShouldUseOrderShowSelfBackWhenOuterBackSafeTest.php new file mode 100644 index 0000000..860aa1a --- /dev/null +++ b/tests/Feature/AdminPlatformOrderShowLeadContextLinkShouldUseOrderShowSelfBackWhenOuterBackSafeTest.php @@ -0,0 +1,98 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_show_should_render_safe_back_but_real_lead_link_should_still_use_order_show_self_back(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'order_show_lead_safe_back_plan', + 'name' => '订单详情线索 safe back 测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $lead = PlatformLead::query()->create([ + 'name' => '订单详情真实线索 safe back', + 'mobile' => '', + 'email' => '', + 'company' => '', + 'source' => 'test', + 'status' => 'new', + 'plan_id' => $plan->id, + 'meta' => ['from' => 'test'], + ]); + + $order = PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'site_subscription_id' => null, + 'created_by_admin_id' => 1, + 'order_no' => 'PO_SHOW_LEAD_SAFE_0001', + 'order_type' => 'new_purchase', + 'status' => 'pending', + 'payment_status' => 'unpaid', + 'payment_channel' => null, + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'list_amount' => 10, + 'discount_amount' => 0, + 'payable_amount' => 10, + 'paid_amount' => 0, + 'placed_at' => now(), + 'plan_snapshot' => ['plan_id' => $plan->id], + 'meta' => ['platform_lead_id' => $lead->id], + 'remark' => 'from lead', + ]); + + $safeBack = '/admin/platform-orders?' . Arr::query([ + 'status' => 'pending', + 'lead_id' => $lead->id, + ]); + + $res = $this->get('/admin/platform-orders/' . $order->id . '?back=' . urlencode($safeBack)); + $res->assertOk(); + + $expectedLeadUrl = '/admin/platform-leads?' . Arr::query([ + 'lead_id' => $lead->id, + 'back' => '/admin/platform-orders/' . $order->id, + ]); + + $res->assertSee('href="' . $safeBack . '"', false); + $res->assertSee('← 返回上一页(保留上下文)'); + $res->assertSee('来源线索:#' . $lead->id, false); + $res->assertSee('href="' . $expectedLeadUrl . '"', false); + $res->assertSee('查看线索', false); + $res->assertDontSee('back%3D', false); + } +}