From 23226150c129b4196a7978ddeb4589b6c79ad561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 11 Mar 2026 09:39:09 +0000 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E8=AE=A2=E5=8D=95=EF=BC=9A?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=A4=B1=E8=B4=A5=E5=8E=9F=E5=9B=A0TOP5?= =?UTF-8?q?=E6=88=AA=E6=96=AD=E5=B1=95=E7=A4=BA=E4=BD=86=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E4=BF=9D=E7=95=99=E5=AE=8C=E6=95=B4=E5=8E=9F=E5=9B=A0=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=8A=A4=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...cFailedReasonTop5TruncateKeepsLinkTest.php | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderSyncFailedReasonTop5TruncateKeepsLinkTest.php diff --git a/tests/Feature/AdminPlatformOrderSyncFailedReasonTop5TruncateKeepsLinkTest.php b/tests/Feature/AdminPlatformOrderSyncFailedReasonTop5TruncateKeepsLinkTest.php new file mode 100644 index 0000000..c6bae1f --- /dev/null +++ b/tests/Feature/AdminPlatformOrderSyncFailedReasonTop5TruncateKeepsLinkTest.php @@ -0,0 +1,79 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_sync_failed_reason_top5_truncate_text_but_keep_full_reason_in_link(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'sync_failed_reason_top5_truncate_keep_link_test', + 'name' => '同步失败原因截断与链接一致性测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $reason = '这是一个很长很长的失败原因,用于测试页面展示会截断但链接必须包含完整原因以确保筛选可复现_1234567890_ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $shown = mb_substr($reason, 0, 60); + + PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_SYNC_FAILED_REASON_TRUNC_0001', + 'order_type' => 'new_purchase', + 'status' => 'activated', + 'payment_status' => 'paid', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'payable_amount' => 10, + 'paid_amount' => 10, + 'placed_at' => now(), + 'paid_at' => now(), + 'activated_at' => now(), + 'meta' => [ + 'subscription_activation_error' => [ + 'message' => $reason, + 'at' => now()->toDateTimeString(), + 'admin_id' => 1, + ], + ], + ]); + + $page = $this->get('/admin/platform-orders'); + $page->assertOk(); + + // 展示应包含截断文本 + $page->assertSee($shown); + + // 链接中应包含完整 reason 的 URL 编码 + $encoded = rawurlencode($reason); + $page->assertSee('sync_error_keyword=' . $encoded, false); + } +}