测试: 补齐摘要区总数链接护栏
This commit is contained in:
@@ -641,7 +641,9 @@
|
||||
<div class="grid-3 mb-20">
|
||||
<div class="card">
|
||||
<h3>平台订单总数</h3>
|
||||
<div class="metric-number">{{ $summaryStats['total_orders'] ?? 0 }}</div>
|
||||
<div class="metric-number">
|
||||
<a data-role="po-summary-link-total-orders" class="link" href="{!! $safeFullUrlWithQuery(['page' => null]) !!}">{{ $summaryStats['total_orders'] ?? 0 }}</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<h3>已支付 / 已生效</h3>
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminPlatformOrderIndexSummaryTotalOrdersLinkShouldHaveDataRoleAndKeepBackTest 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_total_orders_link_should_have_data_role_and_keep_back(): void
|
||||
{
|
||||
$this->loginAsPlatformAdmin();
|
||||
|
||||
$res = $this->get('/admin/platform-orders?merchant_id=1&plan_id=2&back=/admin&page=2');
|
||||
$res->assertOk();
|
||||
|
||||
$html = (string) $res->getContent();
|
||||
|
||||
$re = '/<a[^>]*data-role="po-summary-link-total-orders"[^>]*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);
|
||||
|
||||
$this->assertSame('1', (string) ($q['merchant_id'] ?? ''));
|
||||
$this->assertSame('2', (string) ($q['plan_id'] ?? ''));
|
||||
$this->assertSame('/admin', (string) ($q['back'] ?? ''));
|
||||
$this->assertArrayNotHasKey('page', $q);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user