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); + } +}