From 201635229db1472fa8d75cd1e359010bb0dc58b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 18 Mar 2026 19:11:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95:=20=E8=A1=A5=E9=BD=90?= =?UTF-8?q?=E6=91=98=E8=A6=81=E5=8C=BA=E9=80=80=E6=AC=BE=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=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 | 4 +- ...LinksShouldHaveDataRoleAndKeepBackTest.php | 65 +++++++++++++++++++ 2 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 tests/Feature/AdminPlatformOrderIndexSummaryRefundStatusLinksShouldHaveDataRoleAndKeepBackTest.php diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php index 3954212..58f0320 100644 --- a/resources/views/admin/platform_orders/index.blade.php +++ b/resources/views/admin/platform_orders/index.blade.php @@ -713,9 +713,9 @@

部分退款 / 已退款

diff --git a/tests/Feature/AdminPlatformOrderIndexSummaryRefundStatusLinksShouldHaveDataRoleAndKeepBackTest.php b/tests/Feature/AdminPlatformOrderIndexSummaryRefundStatusLinksShouldHaveDataRoleAndKeepBackTest.php new file mode 100644 index 0000000..a27a9e6 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexSummaryRefundStatusLinksShouldHaveDataRoleAndKeepBackTest.php @@ -0,0 +1,65 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_platform_orders_index_summary_refund_status_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-partially-refunded-orders', + 'expect' => ['payment_status' => 'partially_refunded'], + ], + [ + 'role' => 'po-summary-link-refunded-orders', + 'expect' => ['payment_status' => 'refunded'], + ], + ]; + + 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); + } + } +}