From c5ed4613ad7e9a168e0045ecbfe541dad9aa501c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 18 Mar 2026 16:32:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E9=BD=90=E5=AF=B9=E8=B4=A6/=E9=80=80?= =?UTF-8?q?=E6=AC=BE=E4=B8=8D=E4=B8=80=E8=87=B4=E5=BF=AB=E6=8D=B7=E7=AD=9B?= =?UTF-8?q?=E9=80=89=E4=BF=9D=E7=95=99=E4=B8=8A=E4=B8=8B=E6=96=87=E4=B8=94?= =?UTF-8?q?=E6=B8=85=E7=90=86=E5=B7=A5=E5=85=B7=E5=BC=80=E5=85=B3=E6=8A=A4?= =?UTF-8?q?=E6=A0=8F=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...dInconsistentShouldPreserveContextTest.php | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderIndexQuickFiltersReconcileMismatchAndRefundInconsistentShouldPreserveContextTest.php diff --git a/tests/Feature/AdminPlatformOrderIndexQuickFiltersReconcileMismatchAndRefundInconsistentShouldPreserveContextTest.php b/tests/Feature/AdminPlatformOrderIndexQuickFiltersReconcileMismatchAndRefundInconsistentShouldPreserveContextTest.php new file mode 100644 index 0000000..24d0277 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexQuickFiltersReconcileMismatchAndRefundInconsistentShouldPreserveContextTest.php @@ -0,0 +1,74 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_quick_filters_reconcile_mismatch_and_refund_inconsistent_should_preserve_context_and_clear_toggles(): void + { + $this->loginAsPlatformAdmin(); + + // 模拟用户从“工具型集合/复杂上下文”进入后,点击快捷筛选。 + // 期望:保留必要上下文(merchant_id/created_from/to/back),清理 page,且不继承工具型开关。 + $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) 对账不一致 + $this->assertMatchesRegularExpression('/]*data-role="po-quickfilter-reconcile-mismatch"[^>]*href="([^"]+)"/u', $html); + preg_match('/]*data-role="po-quickfilter-reconcile-mismatch"[^>]*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['reconcile_mismatch'] ?? '')); + $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-refund-inconsistent"[^>]*href="([^"]+)"/u', $html); + preg_match('/]*data-role="po-quickfilter-refund-inconsistent"[^>]*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['refund_inconsistent'] ?? '')); + $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); + + // 说明:页面其他区域(如分页链接)可能会出现 &back= 的转义字符,这里不做全局断言。 + } +}