From 7215b388d6e233cdfa23e4060805f71674f30b96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 18 Mar 2026 15:54:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E9=BD=90=E4=BB=AA=E8=A1=A8=E7=9B=98?= =?UTF-8?q?=E6=94=B6=E8=B4=B9=E5=B7=A5=E4=BD=9C=E5=8F=B0=E5=85=A5=E5=8F=A3?= =?UTF-8?q?=20back=20=E5=8F=82=E6=95=B0=E6=8A=A4=E6=A0=8F=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...benchButtonsShouldIncludeBackQueryTest.php | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tests/Feature/AdminDashboardBillingWorkbenchButtonsShouldIncludeBackQueryTest.php diff --git a/tests/Feature/AdminDashboardBillingWorkbenchButtonsShouldIncludeBackQueryTest.php b/tests/Feature/AdminDashboardBillingWorkbenchButtonsShouldIncludeBackQueryTest.php new file mode 100644 index 0000000..4229d2e --- /dev/null +++ b/tests/Feature/AdminDashboardBillingWorkbenchButtonsShouldIncludeBackQueryTest.php @@ -0,0 +1,53 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_dashboard_billing_workbench_buttons_should_include_back_query(): void + { + $this->loginAsPlatformAdmin(); + + $res = $this->get('/admin'); + $res->assertOk(); + + $html = (string) $res->getContent(); + + $roles = [ + 'dashboard-po-quicklink-bmpa-processable', + 'dashboard-po-quicklink-syncable', + 'dashboard-po-quicklink-sync-failed', + 'dashboard-po-quicklink-paid-no-receipt', + 'dashboard-po-quicklink-reconcile-mismatch', + 'dashboard-po-quicklink-refund-inconsistent', + ]; + + foreach ($roles as $role) { + $this->assertMatchesRegularExpression('/]*data-role="' . preg_quote($role, '/') . '"[^>]*href="([^"]+)"/u', $html); + preg_match('/]*data-role="' . preg_quote($role, '/') . '"[^>]*href="([^"]+)"/u', $html, $m); + $href = html_entity_decode($m[1] ?? ''); + $query = parse_url($href, PHP_URL_QUERY) ?: ''; + parse_str($query, $q); + + $this->assertSame('/admin', (string) ($q['back'] ?? '')); + } + + // 避免 Blade 把 URL escape 成 &back=(会导致 back 被错误编码/叠加) + $res->assertDontSee('&back=', false); + } +}