From 6171041557f2a585d5a6c5f7ba84d1b8f232cd41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 18 Mar 2026 16:37:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E9=BD=90=E6=A0=B8=E5=BF=83=E6=B2=BB?= =?UTF-8?q?=E7=90=86=E5=BF=AB=E6=8D=B7=E7=AD=9B=E9=80=89=E4=BF=9D=E7=95=99?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E6=96=87=E4=B8=94=E6=B8=85=E7=90=86=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E5=BC=80=E5=85=B3=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 --- ...oreGovernanceShouldPreserveContextTest.php | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderIndexQuickFiltersCoreGovernanceShouldPreserveContextTest.php diff --git a/tests/Feature/AdminPlatformOrderIndexQuickFiltersCoreGovernanceShouldPreserveContextTest.php b/tests/Feature/AdminPlatformOrderIndexQuickFiltersCoreGovernanceShouldPreserveContextTest.php new file mode 100644 index 0000000..32d9f27 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexQuickFiltersCoreGovernanceShouldPreserveContextTest.php @@ -0,0 +1,88 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_core_governance_quick_filters_should_preserve_context_and_clear_toggles(): void + { + $this->loginAsPlatformAdmin(); + + $res = $this->get('/admin/platform-orders?merchant_id=1' + . '&created_from=2026-03-01&created_to=2026-03-18' + . '&page=2' + . '&bmpa_failed_only=1&bmpa_error_keyword=timeout&fail_only=1' + . '&back=/admin' + ); + $res->assertOk(); + + $html = (string) $res->getContent(); + + // 1) 可BMPA处理 + $this->assertMatchesRegularExpression('/]*data-role="po-quickfilter-bmpa-processable"[^>]*href="([^"]+)"/u', $html); + preg_match('/]*data-role="po-quickfilter-bmpa-processable"[^>]*href="([^"]+)"/u', $html, $m1); + $href1 = html_entity_decode($m1[1] ?? ''); + $query1 = parse_url($href1, PHP_URL_QUERY) ?: ''; + parse_str($query1, $q1); + + $this->assertSame('1', (string) ($q1['bmpa_processable_only'] ?? '')); + $this->assertSame('1', (string) ($q1['merchant_id'] ?? '')); + $this->assertSame('2026-03-01', (string) ($q1['created_from'] ?? '')); + $this->assertSame('2026-03-18', (string) ($q1['created_to'] ?? '')); + $this->assertSame('/admin', (string) ($q1['back'] ?? '')); + $this->assertArrayNotHasKey('page', $q1); + $this->assertArrayNotHasKey('bmpa_failed_only', $q1); + $this->assertArrayNotHasKey('bmpa_error_keyword', $q1); + $this->assertArrayNotHasKey('fail_only', $q1); + + // 2) 可同步订阅 + $this->assertMatchesRegularExpression('/]*data-role="po-quickfilter-syncable"[^>]*href="([^"]+)"/u', $html); + preg_match('/]*data-role="po-quickfilter-syncable"[^>]*href="([^"]+)"/u', $html, $m2); + $href2 = html_entity_decode($m2[1] ?? ''); + $query2 = parse_url($href2, PHP_URL_QUERY) ?: ''; + parse_str($query2, $q2); + + $this->assertSame('1', (string) ($q2['syncable_only'] ?? '')); + $this->assertSame('unsynced', (string) ($q2['sync_status'] ?? '')); + $this->assertSame('1', (string) ($q2['merchant_id'] ?? '')); + $this->assertSame('2026-03-01', (string) ($q2['created_from'] ?? '')); + $this->assertSame('2026-03-18', (string) ($q2['created_to'] ?? '')); + $this->assertSame('/admin', (string) ($q2['back'] ?? '')); + $this->assertArrayNotHasKey('page', $q2); + $this->assertArrayNotHasKey('bmpa_failed_only', $q2); + $this->assertArrayNotHasKey('bmpa_error_keyword', $q2); + $this->assertArrayNotHasKey('fail_only', $q2); + + // 3) 同步失败 + $this->assertMatchesRegularExpression('/]*data-role="po-quickfilter-sync-failed"[^>]*href="([^"]+)"/u', $html); + preg_match('/]*data-role="po-quickfilter-sync-failed"[^>]*href="([^"]+)"/u', $html, $m3); + $href3 = html_entity_decode($m3[1] ?? ''); + $query3 = parse_url($href3, PHP_URL_QUERY) ?: ''; + parse_str($query3, $q3); + + $this->assertSame('failed', (string) ($q3['sync_status'] ?? '')); + $this->assertSame('1', (string) ($q3['merchant_id'] ?? '')); + $this->assertSame('2026-03-01', (string) ($q3['created_from'] ?? '')); + $this->assertSame('2026-03-18', (string) ($q3['created_to'] ?? '')); + $this->assertSame('/admin', (string) ($q3['back'] ?? '')); + $this->assertArrayNotHasKey('page', $q3); + $this->assertArrayNotHasKey('bmpa_failed_only', $q3); + $this->assertArrayNotHasKey('bmpa_error_keyword', $q3); + $this->assertArrayNotHasKey('fail_only', $q3); + } +}