平台订单:同步失败原因TOP5空原因降级不渲染链接
This commit is contained in:
@@ -244,7 +244,7 @@
|
|||||||
$count = (int) ($item['count'] ?? 0);
|
$count = (int) ($item['count'] ?? 0);
|
||||||
@endphp
|
@endphp
|
||||||
<div>
|
<div>
|
||||||
@if($reason !== '')
|
@if($reason !== '' && $reason !== '(空)')
|
||||||
@php $reasonText = mb_substr($reason, 0, 60); @endphp
|
@php $reasonText = mb_substr($reason, 0, 60); @endphp
|
||||||
<a class="link" title="{{ $reason }}" href="{!! request()->fullUrlWithQuery(['sync_error_keyword' => $reason, 'sync_status' => 'failed', 'page' => null]) !!}">{{ $reasonText }}</a>
|
<a class="link" title="{{ $reason }}" href="{!! request()->fullUrlWithQuery(['sync_error_keyword' => $reason, 'sync_status' => 'failed', 'page' => null]) !!}">{{ $reasonText }}</a>
|
||||||
<span class="muted">({{ $count }})</span>
|
<span class="muted">({{ $count }})</span>
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Models\Merchant;
|
||||||
|
use App\Models\Plan;
|
||||||
|
use App\Models\PlatformOrder;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminPlatformOrderSyncFailedReasonTop5EmptyReasonFallbackTest 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_sync_failed_reason_top5_empty_reason_should_fallback_and_not_render_link(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$merchant = Merchant::query()->firstOrFail();
|
||||||
|
$plan = Plan::query()->create([
|
||||||
|
'code' => 'sync_failed_reason_empty_reason_test',
|
||||||
|
'name' => '同步失败原因空字符串降级测试套餐',
|
||||||
|
'billing_cycle' => 'monthly',
|
||||||
|
'price' => 10,
|
||||||
|
'list_price' => 10,
|
||||||
|
'status' => 'active',
|
||||||
|
'sort' => 10,
|
||||||
|
'published_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// 构造空失败原因(message 为空字符串),确保 TOP5 渲染时走降级展示
|
||||||
|
PlatformOrder::query()->create([
|
||||||
|
'merchant_id' => $merchant->id,
|
||||||
|
'plan_id' => $plan->id,
|
||||||
|
'order_no' => 'PO_SYNC_FAILED_EMPTY_REASON_0001',
|
||||||
|
'order_type' => 'new_purchase',
|
||||||
|
'status' => 'activated',
|
||||||
|
'payment_status' => 'paid',
|
||||||
|
'plan_name' => $plan->name,
|
||||||
|
'billing_cycle' => $plan->billing_cycle,
|
||||||
|
'period_months' => 1,
|
||||||
|
'quantity' => 1,
|
||||||
|
'payable_amount' => 10,
|
||||||
|
'paid_amount' => 10,
|
||||||
|
'placed_at' => now(),
|
||||||
|
'paid_at' => now(),
|
||||||
|
'activated_at' => now(),
|
||||||
|
'meta' => [
|
||||||
|
'subscription_activation_error' => [
|
||||||
|
'message' => '',
|
||||||
|
'at' => now()->toDateTimeString(),
|
||||||
|
'admin_id' => 1,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$page = $this->get('/admin/platform-orders');
|
||||||
|
$page->assertOk();
|
||||||
|
|
||||||
|
$page->assertSee('(空原因)');
|
||||||
|
|
||||||
|
// 空原因不应生成“失败原因链接”或“切到可同步重试”链接
|
||||||
|
$page->assertDontSee('切到可同步重试', false);
|
||||||
|
$page->assertDontSee('sync_error_keyword=', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user