补齐平台订单快捷筛选全部保留 back 且清空筛选护栏测试

This commit is contained in:
萝卜
2026-03-18 16:26:18 +08:00
parent 3d1ebb7a1a
commit 6d1353647b

View File

@@ -0,0 +1,49 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformOrderIndexQuickFilterAllShouldKeepBackAndClearFiltersTest 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_index_quick_filter_all_should_keep_back_and_clear_filters(): void
{
$this->loginAsPlatformAdmin();
$res = $this->get('/admin/platform-orders?merchant_id=1&reconcile_mismatch=1&back=/admin');
$res->assertOk();
$html = (string) $res->getContent();
$this->assertMatchesRegularExpression('/<a[^>]*data-role="po-quickfilter-all"[^>]*href="([^"]+)"/u', $html);
preg_match('/<a[^>]*data-role="po-quickfilter-all"[^>]*href="([^"]+)"/u', $html, $m);
$href = html_entity_decode($m[1] ?? '');
$this->assertNotEmpty($href);
$this->assertSame('/admin/platform-orders', (string) parse_url($href, PHP_URL_PATH));
$query = parse_url($href, PHP_URL_QUERY) ?: '';
parse_str($query, $q);
$this->assertSame('/admin', (string) ($q['back'] ?? ''));
$this->assertArrayNotHasKey('merchant_id', $q);
$this->assertArrayNotHasKey('reconcile_mismatch', $q);
// 避免 Blade 把 back 参数 escape 成 &amp;back= 导致 back 被错误编码/叠加
$res->assertDontSee('&amp;back=', false);
}
}