平台订单摘要批量链接补齐 data-role 与 back 口径护栏
This commit is contained in:
@@ -692,21 +692,21 @@
|
||||
<div class="card">
|
||||
<h3>近24小时批量同步</h3>
|
||||
<div class="metric-number">
|
||||
<a class="link" href="{!! $safeFullUrlWithQuery(['batch_synced_24h' => '1', 'page' => null]) !!}">{{ $summaryStats['batch_synced_24h_orders'] ?? 0 }}</a>
|
||||
<a data-role="po-summary-link-batch-synced-24h-orders" class="link" href="{!! $safeFullUrlWithQuery(['batch_synced_24h' => '1', 'page' => null]) !!}">{{ $summaryStats['batch_synced_24h_orders'] ?? 0 }}</a>
|
||||
</div>
|
||||
<div class="muted muted-xs">基于 meta.batch_activation.at</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h3>近24小时批量BMPA</h3>
|
||||
<div class="metric-number">
|
||||
<a class="link" href="{!! $safeFullUrlWithQuery(['batch_mark_paid_and_activate_24h' => '1', 'page' => null]) !!}">{{ $summaryStats['batch_mark_paid_and_activate_24h_orders'] ?? 0 }}</a>
|
||||
<a data-role="po-summary-link-batch-bmpa-24h-orders" class="link" href="{!! $safeFullUrlWithQuery(['batch_mark_paid_and_activate_24h' => '1', 'page' => null]) !!}">{{ $summaryStats['batch_mark_paid_and_activate_24h_orders'] ?? 0 }}</a>
|
||||
</div>
|
||||
<div class="muted muted-xs">基于 meta.batch_mark_paid_and_activate.at</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h3>近24小时批量生效</h3>
|
||||
<div class="metric-number">
|
||||
<a class="link" href="{!! $safeFullUrlWithQuery(['batch_mark_activated_24h' => '1', 'page' => null]) !!}">{{ $summaryStats['batch_mark_activated_24h_orders'] ?? 0 }}</a>
|
||||
<a data-role="po-summary-link-batch-activated-24h-orders" class="link" href="{!! $safeFullUrlWithQuery(['batch_mark_activated_24h' => '1', 'page' => null]) !!}">{{ $summaryStats['batch_mark_activated_24h_orders'] ?? 0 }}</a>
|
||||
</div>
|
||||
<div class="muted muted-xs">基于 meta.batch_mark_activated.at</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminPlatformOrderIndexSummaryBatchLinksShouldHaveDataRoleAndKeepBackTest 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_summary_batch_links_should_have_data_role_and_keep_back(): void
|
||||
{
|
||||
$this->loginAsPlatformAdmin();
|
||||
|
||||
$res = $this->get('/admin/platform-orders?merchant_id=1&back=/admin&page=2');
|
||||
$res->assertOk();
|
||||
|
||||
$html = (string) $res->getContent();
|
||||
|
||||
$cases = [
|
||||
[
|
||||
'role' => 'po-summary-link-batch-synced-24h-orders',
|
||||
'expect' => ['batch_synced_24h' => '1'],
|
||||
],
|
||||
[
|
||||
'role' => 'po-summary-link-batch-bmpa-24h-orders',
|
||||
'expect' => ['batch_mark_paid_and_activate_24h' => '1'],
|
||||
],
|
||||
[
|
||||
'role' => 'po-summary-link-batch-activated-24h-orders',
|
||||
'expect' => ['batch_mark_activated_24h' => '1'],
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($cases as $c) {
|
||||
$role = (string) ($c['role'] ?? '');
|
||||
$re = '/<a[^>]*data-role="' . preg_quote($role, '/') . '"[^>]*href="([^"]+)"/u';
|
||||
$this->assertMatchesRegularExpression($re, $html);
|
||||
preg_match($re, $html, $m);
|
||||
|
||||
$rawHref = (string) ($m[1] ?? '');
|
||||
$this->assertStringNotContainsString('&back=', $rawHref);
|
||||
|
||||
$href = html_entity_decode($rawHref);
|
||||
$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('/admin', (string) ($q['back'] ?? ''));
|
||||
$this->assertArrayNotHasKey('page', $q);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user