补齐回执/退款状态快捷筛选保留上下文且清理工具开关护栏测试
This commit is contained in:
@@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminPlatformOrderIndexQuickFiltersReceiptAndRefundStatusShouldPreserveContextTest 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_receipt_and_refund_status_quick_filters_should_preserve_context_and_clear_toggles(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$res = $this->get('/admin/platform-orders?merchant_id=1'
|
||||||
|
. '&created_from=2026-03-01&created_to=2026-03-18'
|
||||||
|
. '&page=2'
|
||||||
|
. '&bmpa_failed_only=1&bmpa_error_keyword=timeout&fail_only=1'
|
||||||
|
. '&back=/admin'
|
||||||
|
);
|
||||||
|
$res->assertOk();
|
||||||
|
|
||||||
|
$html = (string) $res->getContent();
|
||||||
|
|
||||||
|
$cases = [
|
||||||
|
[
|
||||||
|
'role' => 'po-quickfilter-receipt-has',
|
||||||
|
'expect' => ['receipt_status' => 'has'],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'role' => 'po-quickfilter-receipt-none',
|
||||||
|
'expect' => ['receipt_status' => 'none'],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'role' => 'po-quickfilter-refund-has',
|
||||||
|
'expect' => ['refund_status' => 'has'],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'role' => 'po-quickfilter-refund-none',
|
||||||
|
'expect' => ['refund_status' => 'none'],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($cases as $c) {
|
||||||
|
$role = (string) ($c['role'] ?? '');
|
||||||
|
$this->assertNotSame('', $role);
|
||||||
|
|
||||||
|
$re = '/<a[^>]*data-role="' . preg_quote($role, '/') . '"[^>]*href="([^"]+)"/u';
|
||||||
|
$this->assertMatchesRegularExpression($re, $html);
|
||||||
|
preg_match($re, $html, $m);
|
||||||
|
|
||||||
|
$href = html_entity_decode($m[1] ?? '');
|
||||||
|
$query = parse_url($href, PHP_URL_QUERY) ?: '';
|
||||||
|
parse_str($query, $q);
|
||||||
|
|
||||||
|
foreach (($c['expect'] ?? []) as $k => $v) {
|
||||||
|
$this->assertSame((string) $v, (string) ($q[$k] ?? ''), $role . ' missing expected ' . $k);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertSame('1', (string) ($q['merchant_id'] ?? ''));
|
||||||
|
$this->assertSame('2026-03-01', (string) ($q['created_from'] ?? ''));
|
||||||
|
$this->assertSame('2026-03-18', (string) ($q['created_to'] ?? ''));
|
||||||
|
$this->assertSame('/admin', (string) ($q['back'] ?? ''));
|
||||||
|
|
||||||
|
$this->assertArrayNotHasKey('page', $q);
|
||||||
|
$this->assertArrayNotHasKey('bmpa_failed_only', $q);
|
||||||
|
$this->assertArrayNotHasKey('bmpa_error_keyword', $q);
|
||||||
|
$this->assertArrayNotHasKey('fail_only', $q);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user