From 69e649db873169b4d70c7d865659af0130f24cd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Fri, 20 Mar 2026 12:55:16 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E9=BD=90=E6=89=B9=E6=AC=A1=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E5=88=B7=E6=96=B0=E5=9B=9E=E9=93=BE=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...BatchShowSelfBackWhenOuterBackSafeTest.php | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 tests/Feature/AdminPlatformBatchShowPageRefreshLinkShouldUseBatchShowSelfBackWhenOuterBackSafeTest.php diff --git a/tests/Feature/AdminPlatformBatchShowPageRefreshLinkShouldUseBatchShowSelfBackWhenOuterBackSafeTest.php b/tests/Feature/AdminPlatformBatchShowPageRefreshLinkShouldUseBatchShowSelfBackWhenOuterBackSafeTest.php new file mode 100644 index 0000000..4d59dc2 --- /dev/null +++ b/tests/Feature/AdminPlatformBatchShowPageRefreshLinkShouldUseBatchShowSelfBackWhenOuterBackSafeTest.php @@ -0,0 +1,100 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_refresh_link_should_use_batch_show_self_back_when_outer_back_safe(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'batch_show_refresh_safe_back_plan', + 'name' => '批次详情刷新回链测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $runId = 'BAS_REFRESH_SAFE_BACK_0001'; + + PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_BATCH_REFRESH_SAFE_BACK_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()->subMinutes(10), + 'paid_at' => now()->subMinutes(9), + 'activated_at' => now()->subMinutes(8), + 'meta' => [ + 'batch_activation' => [ + 'run_id' => $runId, + 'last_result' => [ + 'run_id' => $runId, + 'success' => 1, + 'failed' => 0, + 'matched' => 1, + 'processed' => 1, + 'top_reasons' => [], + 'at' => now()->toDateTimeString(), + ], + ], + ], + ]); + + $safeBack = '/admin/platform-orders?' . Arr::query([ + 'status' => 'pending', + 'keyword' => '批次刷新', + ]); + + $res = $this->get('/admin/platform-batches/show?type=bas&run_id=' . $runId . '&back=' . urlencode($safeBack)); + $res->assertOk(); + + $batchShowSelf = '/admin/platform-batches/show?' . Arr::query([ + 'type' => 'bas', + 'run_id' => $runId, + ]); + $expectedRefreshUrl = '/admin/platform-batches/show?' . Arr::query([ + 'type' => 'bas', + 'run_id' => $runId, + 'back' => $batchShowSelf, + ]); + + $res->assertSee(str_replace('&', '&', $safeBack), false); + $res->assertSee('返回上一页'); + $res->assertSee($expectedRefreshUrl, false); + $res->assertDontSee('run_id=' . $runId . '&back=' . $safeBack, false); + $res->assertDontSee('back%3D', false); + } +}