From 797f438c29e3bb4b364979efbfc4044c35c90ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Sun, 15 Mar 2026 07:33:03 +0000 Subject: [PATCH] =?UTF-8?q?test(admin):=20=E7=BB=AD=E8=B4=B9=E7=BC=BA?= =?UTF-8?q?=E8=AE=A2=E9=98=85=E5=BF=AB=E6=8D=B7=E7=AD=9B=E9=80=89=E5=BA=94?= =?UTF-8?q?=E4=BF=9D=E7=95=99=E4=B8=8A=E4=B8=8B=E6=96=87=E5=B9=B6=E6=B8=85?= =?UTF-8?q?=E7=90=86=E4=BA=92=E6=96=A5=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ssingSubscriptionShouldKeepContextTest.php | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderIndexQuickFilterRenewalMissingSubscriptionShouldKeepContextTest.php diff --git a/tests/Feature/AdminPlatformOrderIndexQuickFilterRenewalMissingSubscriptionShouldKeepContextTest.php b/tests/Feature/AdminPlatformOrderIndexQuickFilterRenewalMissingSubscriptionShouldKeepContextTest.php new file mode 100644 index 0000000..ec8a922 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexQuickFilterRenewalMissingSubscriptionShouldKeepContextTest.php @@ -0,0 +1,57 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_quick_filter_renewal_missing_subscription_should_keep_context_and_drop_other_filters(): void + { + $this->loginAsPlatformAdmin(); + + // 模拟:当前已筛选站点/套餐/订阅ID/线索,并且带一堆其它筛选(可能互斥),以及 page/back + $res = $this->get('/admin/platform-orders?lead_id=12&merchant_id=2&plan_id=3&site_subscription_id=4&page=9&back=%2Fadmin%2Fplans&syncable_only=1&reconcile_mismatch=1&refund_inconsistent=1&receipt_status=has'); + $res->assertOk(); + + $html = (string) $res->getContent(); + + // 精确抓取“快捷筛选”里的“续费缺订阅”链接(避免匹配到汇总卡片) + $matched = preg_match('/]+href="([^"]+)"[^>]*>\s*续费缺订阅\s*<\/a>/u', $html, $m); + $this->assertSame(1, $matched, '未找到快捷筛选:续费缺订阅 链接'); + + $url = $m[1] ?? ''; + $parts = parse_url($url); + parse_str($parts['query'] ?? '', $q); + + // 应保留上下文:lead/merchant/plan/subscription/back + $this->assertSame('12', (string) ($q['lead_id'] ?? '')); + $this->assertSame('2', (string) ($q['merchant_id'] ?? '')); + $this->assertSame('3', (string) ($q['plan_id'] ?? '')); + $this->assertSame('4', (string) ($q['site_subscription_id'] ?? '')); + $this->assertSame('/admin/plans', (string) ($q['back'] ?? '')); + + // 应覆盖 renewal_missing_subscription + $this->assertSame('1', (string) ($q['renewal_missing_subscription'] ?? '')); + + // 并且:不应携带其它互斥筛选字段,避免叠加导致空结果 + $this->assertArrayNotHasKey('page', $q); + $this->assertArrayNotHasKey('syncable_only', $q); + $this->assertArrayNotHasKey('reconcile_mismatch', $q); + $this->assertArrayNotHasKey('refund_inconsistent', $q); + $this->assertArrayNotHasKey('receipt_status', $q); + } +}