平台订单列表:订阅号链接 back 去嵌套并加护栏测试
This commit is contained in:
@@ -802,10 +802,11 @@
|
||||
@if($order->siteSubscription)
|
||||
<div>
|
||||
@php
|
||||
$backUri = request()->getRequestUri();
|
||||
$subLink = '/admin/site-subscriptions/' . $order->siteSubscription->id . '?' . \Illuminate\Support\Arr::query(['back' => $backUri]);
|
||||
// 与本页“订单号 -> 详情页 back”口径一致:订阅详情 back 回到本页自身(剔除 back query,避免嵌套)
|
||||
$subBack = $selfWithoutBack;
|
||||
$subLink = '/admin/site-subscriptions/' . $order->siteSubscription->id . '?' . \Illuminate\Support\Arr::query(['back' => $subBack]);
|
||||
@endphp
|
||||
<a href="{{ $subLink }}">{{ $order->siteSubscription->subscription_no }}</a>
|
||||
<a href="{!! $subLink !!}">{{ $order->siteSubscription->subscription_no }}</a>
|
||||
</div>
|
||||
<div class="muted muted-xs">
|
||||
订阅ID:<a href="{!! request()->fullUrlWithQuery(['site_subscription_id' => $order->siteSubscription->id, 'page' => null]) !!}" class="muted">{{ $order->siteSubscription->id }}</a>
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\Merchant;
|
||||
use App\Models\Plan;
|
||||
use App\Models\PlatformOrder;
|
||||
use App\Models\SiteSubscription;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Arr;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminPlatformOrderIndexSubscriptionNoLinkContainsBackToSelfWithoutBackTest 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_subscription_no_link_should_carry_back_to_platform_orders_index_without_nested_back(): void
|
||||
{
|
||||
$this->loginAsPlatformAdmin();
|
||||
|
||||
$merchant = Merchant::query()->firstOrFail();
|
||||
$plan = Plan::query()->create([
|
||||
'code' => 'po_index_sub_no_back_plan',
|
||||
'name' => '平台订单列表订阅号 back 口径测试套餐',
|
||||
'billing_cycle' => 'monthly',
|
||||
'price' => 10,
|
||||
'list_price' => 10,
|
||||
'status' => 'active',
|
||||
'sort' => 10,
|
||||
'published_at' => now(),
|
||||
]);
|
||||
|
||||
$sub = SiteSubscription::query()->create([
|
||||
'merchant_id' => $merchant->id,
|
||||
'plan_id' => $plan->id,
|
||||
'status' => 'activated',
|
||||
'source' => 'manual',
|
||||
'subscription_no' => 'SUB_PO_INDEX_BACK_0001',
|
||||
'plan_name' => $plan->name,
|
||||
'billing_cycle' => $plan->billing_cycle,
|
||||
'period_months' => 1,
|
||||
'amount' => 10,
|
||||
'starts_at' => now()->subDay(),
|
||||
'ends_at' => now()->addMonth(),
|
||||
'activated_at' => now()->subDay(),
|
||||
]);
|
||||
|
||||
PlatformOrder::query()->create([
|
||||
'merchant_id' => $merchant->id,
|
||||
'plan_id' => $plan->id,
|
||||
'site_subscription_id' => $sub->id,
|
||||
'order_no' => 'PO_INDEX_BACK_0001',
|
||||
'order_type' => 'new_purchase',
|
||||
'status' => 'pending',
|
||||
'payment_status' => 'unpaid',
|
||||
'plan_name' => $plan->name,
|
||||
'billing_cycle' => $plan->billing_cycle,
|
||||
'period_months' => 1,
|
||||
'quantity' => 1,
|
||||
'payable_amount' => 10,
|
||||
'paid_amount' => 0,
|
||||
'placed_at' => now(),
|
||||
'meta' => [],
|
||||
]);
|
||||
|
||||
// 带 back 访问列表页(模拟从其它页面跳回)
|
||||
$res = $this->get('/admin/platform-orders?status=pending&back=' . urlencode('/admin/plans'));
|
||||
$res->assertOk();
|
||||
|
||||
// 订阅号链接的 back 应该回到列表页自身(去掉 back query),不应包含嵌套 back
|
||||
$expectedBack = '/admin/platform-orders?' . Arr::query([
|
||||
'status' => 'pending',
|
||||
]);
|
||||
|
||||
$expectedSubUrl = '/admin/site-subscriptions/' . $sub->id . '?' . Arr::query([
|
||||
'back' => $expectedBack,
|
||||
]);
|
||||
|
||||
$res->assertSee($expectedSubUrl, false);
|
||||
$res->assertDontSee('back%3D', false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user