test: 套餐列表导出表单透传筛选口径护栏
This commit is contained in:
50
tests/Feature/AdminPlanIndexKeepFiltersOnLinksTest.php
Normal file
50
tests/Feature/AdminPlanIndexKeepFiltersOnLinksTest.php
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Models\Plan;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminPlanIndexKeepFiltersOnLinksTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
protected function loginAsPlatformAdmin(): void
|
||||||
|
{
|
||||||
|
$this->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('<form method="get" action="/admin/plans/export">', false);
|
||||||
|
$res->assertSee('<input type="hidden" name="status" value="active">', false);
|
||||||
|
$res->assertSee('<input type="hidden" name="published" value="published">', false);
|
||||||
|
$res->assertSee('<input type="hidden" name="billing_cycle" value="monthly">', false);
|
||||||
|
|
||||||
|
// keyword 可能包含 URL 编码字符,这里只校验 name 存在,避免脆弱断言
|
||||||
|
$res->assertSee('name="keyword"', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user