From 6d1353647be6113fd32358130d8b4de76a07ddca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 18 Mar 2026 16:26:18 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E9=BD=90=E5=B9=B3=E5=8F=B0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=BF=AB=E6=8D=B7=E7=AD=9B=E9=80=89=E5=85=A8=E9=83=A8?= =?UTF-8?q?=E4=BF=9D=E7=95=99=20back=20=E4=B8=94=E6=B8=85=E7=A9=BA?= =?UTF-8?q?=E7=AD=9B=E9=80=89=E6=8A=A4=E6=A0=8F=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...erAllShouldKeepBackAndClearFiltersTest.php | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderIndexQuickFilterAllShouldKeepBackAndClearFiltersTest.php diff --git a/tests/Feature/AdminPlatformOrderIndexQuickFilterAllShouldKeepBackAndClearFiltersTest.php b/tests/Feature/AdminPlatformOrderIndexQuickFilterAllShouldKeepBackAndClearFiltersTest.php new file mode 100644 index 0000000..eecadf3 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexQuickFilterAllShouldKeepBackAndClearFiltersTest.php @@ -0,0 +1,49 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_platform_orders_index_quick_filter_all_should_keep_back_and_clear_filters(): void + { + $this->loginAsPlatformAdmin(); + + $res = $this->get('/admin/platform-orders?merchant_id=1&reconcile_mismatch=1&back=/admin'); + $res->assertOk(); + + $html = (string) $res->getContent(); + + $this->assertMatchesRegularExpression('/]*data-role="po-quickfilter-all"[^>]*href="([^"]+)"/u', $html); + preg_match('/]*data-role="po-quickfilter-all"[^>]*href="([^"]+)"/u', $html, $m); + + $href = html_entity_decode($m[1] ?? ''); + $this->assertNotEmpty($href); + + $this->assertSame('/admin/platform-orders', (string) parse_url($href, PHP_URL_PATH)); + + $query = parse_url($href, PHP_URL_QUERY) ?: ''; + parse_str($query, $q); + + $this->assertSame('/admin', (string) ($q['back'] ?? '')); + $this->assertArrayNotHasKey('merchant_id', $q); + $this->assertArrayNotHasKey('reconcile_mismatch', $q); + + // 避免 Blade 把 back 参数 escape 成 &back= 导致 back 被错误编码/叠加 + $res->assertDontSee('&back=', false); + } +}