From 7614ada1b60142d5d9f20dbfb3558dec7e323195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 18 Mar 2026 18:41:25 +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=E7=8A=B6=E6=80=81=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 | 10 ++-- ...LinksShouldHaveDataRoleAndKeepBackTest.php | 60 +++++++++++++++++++ 2 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 tests/Feature/AdminPlatformOrderIndexSummaryStatusLinksShouldHaveDataRoleAndKeepBackTest.php diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php index a9cfc2f..734d4f3 100644 --- a/resources/views/admin/platform_orders/index.blade.php +++ b/resources/views/admin/platform_orders/index.blade.php @@ -646,23 +646,23 @@

已支付 / 已生效

已同步 / 未同步

同步失败数

diff --git a/tests/Feature/AdminPlatformOrderIndexSummaryStatusLinksShouldHaveDataRoleAndKeepBackTest.php b/tests/Feature/AdminPlatformOrderIndexSummaryStatusLinksShouldHaveDataRoleAndKeepBackTest.php new file mode 100644 index 0000000..5665b8b --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexSummaryStatusLinksShouldHaveDataRoleAndKeepBackTest.php @@ -0,0 +1,60 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_platform_orders_index_summary_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-paid-orders', 'expect' => ['payment_status' => 'paid']], + ['role' => 'po-summary-link-activated-orders', 'expect' => ['status' => 'activated']], + ['role' => 'po-summary-link-synced-orders', 'expect' => ['sync_status' => 'synced']], + ['role' => 'po-summary-link-unsynced-orders', 'expect' => ['sync_status' => 'unsynced']], + ['role' => 'po-summary-link-sync-failed-orders', 'expect' => ['sync_status' => 'failed']], + ]; + + 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'] ?? '')); + $this->assertArrayNotHasKey('page', $q); + } + } +}