diff --git a/tests/Feature/AdminPlanIndexKeepFiltersOnLinksTest.php b/tests/Feature/AdminPlanIndexKeepFiltersOnLinksTest.php new file mode 100644 index 0000000..ee581fa --- /dev/null +++ b/tests/Feature/AdminPlanIndexKeepFiltersOnLinksTest.php @@ -0,0 +1,50 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_plans_index_tools_export_form_keeps_filters(): void + { + $this->loginAsPlatformAdmin(); + + Plan::query()->create([ + 'code' => 'plan_keep_filters_01', + 'name' => '筛选透传测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 9.9, + 'list_price' => 9.9, + 'status' => 'active', + 'sort' => 1, + 'published_at' => now(), + ]); + + $res = $this->get('/admin/plans?status=active&billing_cycle=monthly&published=published&keyword=' . urlencode('筛选')); + $res->assertOk(); + + // 导出表单 hidden input 透传筛选口径 + $res->assertSee('
', false); + $res->assertSee('', false); + $res->assertSee('', false); + $res->assertSee('', false); + + // keyword 可能包含 URL 编码字符,这里只校验 name 存在,避免脆弱断言 + $res->assertSee('name="keyword"', false); + } +}