From 47669f1cf816bb8572c855dde04eefd0d1ede5c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 18 Mar 2026 16:46:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E9=BD=90=E5=9B=9E=E6=89=A7/=E9=80=80?= =?UTF-8?q?=E6=AC=BE=E7=8A=B6=E6=80=81=E5=BF=AB=E6=8D=B7=E7=AD=9B=E9=80=89?= =?UTF-8?q?=E4=BF=9D=E7=95=99=E4=B8=8A=E4=B8=8B=E6=96=87=E4=B8=94=E6=B8=85?= =?UTF-8?q?=E7=90=86=E5=B7=A5=E5=85=B7=E5=BC=80=E5=85=B3=E6=8A=A4=E6=A0=8F?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...dRefundStatusShouldPreserveContextTest.php | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderIndexQuickFiltersReceiptAndRefundStatusShouldPreserveContextTest.php diff --git a/tests/Feature/AdminPlatformOrderIndexQuickFiltersReceiptAndRefundStatusShouldPreserveContextTest.php b/tests/Feature/AdminPlatformOrderIndexQuickFiltersReceiptAndRefundStatusShouldPreserveContextTest.php new file mode 100644 index 0000000..0c1fd0f --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexQuickFiltersReceiptAndRefundStatusShouldPreserveContextTest.php @@ -0,0 +1,82 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_receipt_and_refund_status_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(); + + $cases = [ + [ + 'role' => 'po-quickfilter-receipt-has', + 'expect' => ['receipt_status' => 'has'], + ], + [ + 'role' => 'po-quickfilter-receipt-none', + 'expect' => ['receipt_status' => 'none'], + ], + [ + 'role' => 'po-quickfilter-refund-has', + 'expect' => ['refund_status' => 'has'], + ], + [ + 'role' => 'po-quickfilter-refund-none', + 'expect' => ['refund_status' => 'none'], + ], + ]; + + foreach ($cases as $c) { + $role = (string) ($c['role'] ?? ''); + $this->assertNotSame('', $role); + + $re = '/]*data-role="' . preg_quote($role, '/') . '"[^>]*href="([^"]+)"/u'; + $this->assertMatchesRegularExpression($re, $html); + preg_match($re, $html, $m); + + $href = html_entity_decode($m[1] ?? ''); + $query = parse_url($href, PHP_URL_QUERY) ?: ''; + parse_str($query, $q); + + foreach (($c['expect'] ?? []) as $k => $v) { + $this->assertSame((string) $v, (string) ($q[$k] ?? ''), $role . ' missing expected ' . $k); + } + + $this->assertSame('1', (string) ($q['merchant_id'] ?? '')); + $this->assertSame('2026-03-01', (string) ($q['created_from'] ?? '')); + $this->assertSame('2026-03-18', (string) ($q['created_to'] ?? '')); + $this->assertSame('/admin', (string) ($q['back'] ?? '')); + + $this->assertArrayNotHasKey('page', $q); + $this->assertArrayNotHasKey('bmpa_failed_only', $q); + $this->assertArrayNotHasKey('bmpa_error_keyword', $q); + $this->assertArrayNotHasKey('fail_only', $q); + } + } +}