tests(platform-orders): add guard for created-at range quick links
This commit is contained in:
@@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminPlatformOrderCreatedAtRangeQuickLinksShouldRenderTest 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_platform_orders_created_at_range_quick_links_should_render_and_keep_safe_back(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$res = $this->get('/admin/platform-orders?back=%2Fadmin&payment_status=paid');
|
||||||
|
$res->assertOk();
|
||||||
|
|
||||||
|
$res->assertSee('data-role="platform-orders-created-range-quick-links"', false);
|
||||||
|
|
||||||
|
$res->assertSee('data-role="po-created-range-today"', false);
|
||||||
|
$res->assertSee('data-role="po-created-range-7d"', false);
|
||||||
|
$res->assertSee('data-role="po-created-range-30d"', false);
|
||||||
|
$res->assertSee('data-role="po-created-range-clear"', false);
|
||||||
|
|
||||||
|
// back 必须保留且不应被 escape 成 &back
|
||||||
|
$res->assertSee('back=%2Fadmin', false);
|
||||||
|
$res->assertDontSee('&back=', false);
|
||||||
|
|
||||||
|
// 应保留原有筛选上下文(例如 payment_status=paid)
|
||||||
|
$res->assertSee('payment_status=paid', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user