From 04e823ec0a8e9ad41ad95614dbb05904333e7b39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 18 Mar 2026 18:27:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E8=AE=A2=E5=8D=95=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=9B=9E=E6=89=A7=E9=80=80=E6=AC=BE=E6=91=98=E8=A6=81?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E8=A1=A5=E9=BD=90=20data-role=20=E4=B8=8E=20?= =?UTF-8?q?back=20=E6=8A=A4=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/platform_orders/index.blade.php | 8 +- ...LinksShouldHaveDataRoleAndKeepBackTest.php | 73 +++++++++++++++++++ 2 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 tests/Feature/AdminPlatformOrderIndexSummaryReceiptRefundLinksShouldHaveDataRoleAndKeepBackTest.php diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php index da357d8..2ad12f6 100644 --- a/resources/views/admin/platform_orders/index.blade.php +++ b/resources/views/admin/platform_orders/index.blade.php @@ -729,16 +729,16 @@

有退款订单 / 无退款订单

口径:refund_summary.total_amount 存在或 refund_receipts 有记录

有回执订单 / 回执总额

- {{ $summaryStats['receipt_orders'] ?? 0 }} + {{ $summaryStats['receipt_orders'] ?? 0 }} / ¥{{ number_format((float) ($summaryStats['total_receipt_amount'] ?? 0), 2) }}
有回执口径:payment_summary.total_amount 存在或 payment_receipts 有记录
@@ -749,7 +749,7 @@

无回执订单

无 payment_summary 且无 payment_receipts
diff --git a/tests/Feature/AdminPlatformOrderIndexSummaryReceiptRefundLinksShouldHaveDataRoleAndKeepBackTest.php b/tests/Feature/AdminPlatformOrderIndexSummaryReceiptRefundLinksShouldHaveDataRoleAndKeepBackTest.php new file mode 100644 index 0000000..c6acb3e --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexSummaryReceiptRefundLinksShouldHaveDataRoleAndKeepBackTest.php @@ -0,0 +1,73 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_platform_orders_index_summary_receipt_refund_links_should_have_data_role_and_keep_back(): void + { + $this->loginAsPlatformAdmin(); + + $res = $this->get('/admin/platform-orders?merchant_id=1&back=/admin&page=2'); + $res->assertOk(); + + $html = (string) $res->getContent(); + + $cases = [ + [ + 'role' => 'po-summary-link-refund-orders', + 'expect' => ['refund_status' => 'has'], + ], + [ + 'role' => 'po-summary-link-no-refund-orders', + 'expect' => ['refund_status' => 'none'], + ], + [ + 'role' => 'po-summary-link-receipt-orders', + 'expect' => ['receipt_status' => 'has'], + ], + [ + 'role' => 'po-summary-link-no-receipt-orders', + 'expect' => ['receipt_status' => 'none'], + ], + ]; + + foreach ($cases as $c) { + $role = (string) ($c['role'] ?? ''); + $this->assertNotSame('', $role); + + $re = '/]*data-role="' . preg_quote($role, '/') . '"[^>]*href="([^"]+)"/u'; + $this->assertMatchesRegularExpression($re, $html); + preg_match($re, $html, $m); + + $rawHref = (string) ($m[1] ?? ''); + $this->assertStringNotContainsString('&back=', $rawHref); + + $href = html_entity_decode($rawHref); + $query = parse_url($href, PHP_URL_QUERY) ?: ''; + parse_str($query, $q); + + foreach (($c['expect'] ?? []) as $k => $v) { + $this->assertSame((string) $v, (string) ($q[$k] ?? ''), $role . ' missing expected ' . $k); + } + + $this->assertSame('/admin', (string) ($q['back'] ?? '')); + $this->assertArrayNotHasKey('page', $q); + } + } +}