From 86c0cf532af27f53314a25fa2ae2adeef7e1bc11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 18 Mar 2026 16:42:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E9=BD=90=20BMPA=20=E6=88=90=E5=8A=9F/?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E5=BF=AB=E6=8D=B7=E7=AD=9B=E9=80=89=E4=BF=9D?= =?UTF-8?q?=E7=95=99=E4=B8=8A=E4=B8=8B=E6=96=87=E4=B8=94=E6=B8=85=E7=90=86?= =?UTF-8?q?=E4=BA=92=E6=96=A5=E5=BC=80=E5=85=B3=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 --- ...ledAndSuccessShouldPreserveContextTest.php | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderIndexQuickFiltersBmpaFailedAndSuccessShouldPreserveContextTest.php diff --git a/tests/Feature/AdminPlatformOrderIndexQuickFiltersBmpaFailedAndSuccessShouldPreserveContextTest.php b/tests/Feature/AdminPlatformOrderIndexQuickFiltersBmpaFailedAndSuccessShouldPreserveContextTest.php new file mode 100644 index 0000000..4b9d926 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexQuickFiltersBmpaFailedAndSuccessShouldPreserveContextTest.php @@ -0,0 +1,76 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_bmpa_failed_and_success_quick_filters_should_preserve_context_and_clear_toggles(): void + { + $this->loginAsPlatformAdmin(); + + // 从复杂 query 进入:包含上下文 + 工具型互斥开关 + $res = $this->get('/admin/platform-orders?merchant_id=1' + . '&created_from=2026-03-01&created_to=2026-03-18' + . '&page=2' + . '&fail_only=1&sync_status=failed&syncable_only=1' + . '&bmpa_error_keyword=timeout' + . '&back=/admin' + ); + $res->assertOk(); + + $html = (string) $res->getContent(); + + // 1) BMPA失败 + $this->assertMatchesRegularExpression('/]*data-role="po-quickfilter-bmpa-failed"[^>]*href="([^"]+)"/u', $html); + preg_match('/]*data-role="po-quickfilter-bmpa-failed"[^>]*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_failed_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('fail_only', $q1); + $this->assertArrayNotHasKey('sync_status', $q1); + $this->assertArrayNotHasKey('syncable_only', $q1); + $this->assertArrayNotHasKey('bmpa_error_keyword', $q1); + + // 2) BMPA成功 + $this->assertMatchesRegularExpression('/]*data-role="po-quickfilter-bmpa-success"[^>]*href="([^"]+)"/u', $html); + preg_match('/]*data-role="po-quickfilter-bmpa-success"[^>]*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['bmpa_success_only'] ?? '')); + $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('fail_only', $q2); + $this->assertArrayNotHasKey('sync_status', $q2); + $this->assertArrayNotHasKey('syncable_only', $q2); + $this->assertArrayNotHasKey('bmpa_error_keyword', $q2); + } +}