From 35aa1295e8e5c5a58bb5314553204f91084f9d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Tue, 17 Mar 2026 11:11:12 +0800 Subject: [PATCH] test(platform-orders): guard export ledger links param order on show page --- ...rLinksShouldStartWithDownloadParamTest.php | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderShowExportLedgerLinksShouldStartWithDownloadParamTest.php diff --git a/tests/Feature/AdminPlatformOrderShowExportLedgerLinksShouldStartWithDownloadParamTest.php b/tests/Feature/AdminPlatformOrderShowExportLedgerLinksShouldStartWithDownloadParamTest.php new file mode 100644 index 0000000..18a479d --- /dev/null +++ b/tests/Feature/AdminPlatformOrderShowExportLedgerLinksShouldStartWithDownloadParamTest.php @@ -0,0 +1,71 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_show_page_export_ledger_links_should_start_with_download_param_for_safety_and_stability(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + + $plan = Plan::query()->create([ + 'code' => 'po_show_export_ledger_link_order_01', + 'name' => '平台订单详情导出链接顺序护栏测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $order = PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_SHOW_EXPORT_LEDGER_LINK_ORDER_0001', + 'order_type' => 'new_purchase', + 'status' => 'pending', + 'payment_status' => 'unpaid', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'payable_amount' => 10, + 'paid_amount' => 0, + 'placed_at' => now(), + 'meta' => [], + ]); + + $res = $this->get('/admin/platform-orders/' . $order->id); + $res->assertOk(); + + $base = '/admin/platform-orders/' . $order->id . '/export-ledger?download=1'; + $withSnapshot = '/admin/platform-orders/' . $order->id . '/export-ledger?download=1&include_order_snapshot=1'; + + $res->assertSee($base, false); + $res->assertSee($withSnapshot, false); + + // 反向断言:不允许 include_order_snapshot 出现在 download 之前(保持 URL 口径稳定,避免回退时测试/前端混乱) + $res->assertDontSee('/admin/platform-orders/' . $order->id . '/export-ledger?include_order_snapshot=1&download=1', false); + } +}