From e3bec58774c16ec5d9e9d93585550fa0da4c05db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 18 Mar 2026 18:29:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E8=AE=A2=E5=8D=95=E6=91=98?= =?UTF-8?q?=E8=A6=81=E6=B2=BB=E7=90=86=E9=93=BE=E6=8E=A5=E8=A1=A5=E9=BD=90?= =?UTF-8?q?=20data-role=20=E4=B8=8E=20back=20=E5=8F=A3=E5=BE=84=E6=8A=A4?= =?UTF-8?q?=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 | 78 +++++++++++++++++++ 2 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 tests/Feature/AdminPlatformOrderIndexSummaryGovernanceLinksShouldHaveDataRoleAndKeepBackTest.php diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php index 2ad12f6..c32e9d9 100644 --- a/resources/views/admin/platform_orders/index.blade.php +++ b/resources/views/admin/platform_orders/index.blade.php @@ -668,23 +668,23 @@

BMPA 成功 / 失败

成功口径:存在 run_id 且无 error.message;失败口径:meta 失败标记

可同步订单

已支付 + 已生效 + 未同步(续费单需已绑定订阅)

续费缺订阅

renewal + site_subscription_id 为空(需治理:去订单详情补订阅/核对来源)
diff --git a/tests/Feature/AdminPlatformOrderIndexSummaryGovernanceLinksShouldHaveDataRoleAndKeepBackTest.php b/tests/Feature/AdminPlatformOrderIndexSummaryGovernanceLinksShouldHaveDataRoleAndKeepBackTest.php new file mode 100644 index 0000000..4bd3918 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexSummaryGovernanceLinksShouldHaveDataRoleAndKeepBackTest.php @@ -0,0 +1,78 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_platform_orders_index_summary_governance_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-bmpa-success-orders', + 'expect' => ['bmpa_success_only' => '1'], + 'must_not_have' => ['page'], + ], + [ + 'role' => 'po-summary-link-bmpa-failed-orders', + 'expect' => ['bmpa_failed_only' => '1'], + 'must_not_have' => ['page', 'fail_only'], + ], + [ + 'role' => 'po-summary-link-syncable-orders', + 'expect' => ['syncable_only' => '1', 'sync_status' => 'unsynced'], + 'must_not_have' => ['page', 'fail_only'], + ], + [ + 'role' => 'po-summary-link-renewal-missing-sub-orders', + 'expect' => ['renewal_missing_subscription' => '1'], + 'must_not_have' => ['page'], + ], + ]; + + foreach ($cases as $c) { + $role = (string) ($c['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'] ?? '')); + + foreach (($c['must_not_have'] ?? []) as $key) { + $this->assertArrayNotHasKey((string) $key, $q, $role . ' should clear ' . $key); + } + } + } +}