From 506f5c17baa644e01b59bb3cd54c459e2093262d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 18 Mar 2026 13:53:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95:=20=E5=BF=AB=E6=8D=B7?= =?UTF-8?q?=E7=AD=9B=E9=80=89=E4=B8=8D=E7=BB=A7=E6=89=BF=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E5=9E=8B=E5=BC=80=E5=85=B3=E6=8A=A4=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...FiltersShouldNotInheritToolTogglesTest.php | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderIndexQuickFiltersShouldNotInheritToolTogglesTest.php diff --git a/tests/Feature/AdminPlatformOrderIndexQuickFiltersShouldNotInheritToolTogglesTest.php b/tests/Feature/AdminPlatformOrderIndexQuickFiltersShouldNotInheritToolTogglesTest.php new file mode 100644 index 0000000..059140f --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexQuickFiltersShouldNotInheritToolTogglesTest.php @@ -0,0 +1,57 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_quick_filters_should_not_inherit_tool_toggles(): void + { + $this->loginAsPlatformAdmin(); + + // 模拟用户从某个“工具型集合”进入(fail_only/bmpa_failed_only 等), + // 再点击快捷筛选时,不应把这些工具型开关继承过去,避免叠加冲突导致空结果。 + $res = $this->get('/admin/platform-orders?merchant_id=1&bmpa_failed_only=1&fail_only=1'); + $res->assertOk(); + + $html = (string) $res->getContent(); + + // 1) 快捷筛选:同步失败 + $this->assertMatchesRegularExpression('/]*href="([^"]+)"[^>]*class="muted"[^>]*>同步失败<\/a>/', $html); + preg_match('/]*href="([^"]+)"[^>]*class="muted"[^>]*>同步失败<\/a>/', $html, $m1); + $href1 = html_entity_decode($m1[1] ?? ''); + $query1 = parse_url($href1, PHP_URL_QUERY) ?: ''; + parse_str($query1, $q1); + + $this->assertSame('failed', (string) ($q1['sync_status'] ?? '')); + $this->assertSame('1', (string) ($q1['merchant_id'] ?? '')); + $this->assertArrayNotHasKey('bmpa_failed_only', $q1); + $this->assertArrayNotHasKey('fail_only', $q1); + + // 2) 快捷筛选:可BMPA处理 + $this->assertMatchesRegularExpression('/]*href="([^"]+)"[^>]*class="muted"[^>]*>可BMPA处理<\/a>/', $html); + preg_match('/]*href="([^"]+)"[^>]*class="muted"[^>]*>可BMPA处理<\/a>/', $html, $m2); + $href2 = html_entity_decode($m2[1] ?? ''); + $query2 = parse_url($href2, PHP_URL_QUERY) ?: ''; + parse_str($query2, $q2); + + $this->assertSame('1', (string) ($q2['bmpa_processable_only'] ?? '')); + $this->assertSame('1', (string) ($q2['merchant_id'] ?? '')); + $this->assertArrayNotHasKey('bmpa_failed_only', $q2); + $this->assertArrayNotHasKey('fail_only', $q2); + } +}