平台订单创建页:去订阅管理选择订阅的 back 保持 require_subscription=1 并新增测试
This commit is contained in:
@@ -177,7 +177,16 @@
|
|||||||
$jumpBase .= '?' . \Illuminate\Support\Arr::query($jumpQuery);
|
$jumpBase .= '?' . \Illuminate\Support\Arr::query($jumpQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
$jumpUrl = \App\Support\BackUrl::withBack($jumpBase, \App\Support\BackUrl::selfWithoutBack());
|
$createSelfForBack = \App\Support\BackUrl::selfWithoutBack();
|
||||||
|
// 若 require_subscription 来自 old input(校验失败回填),当前 URL 可能不带 query,
|
||||||
|
// 此时也需要把 require_subscription=1 写回到 back,避免“去订阅管理选择订阅”回来后治理口径丢失。
|
||||||
|
if (($requireSubscription ?? false) || ((string) old('require_subscription', '') === '1')) {
|
||||||
|
$createSelfForBack = \App\Support\BackUrl::currentPathWithQuery([
|
||||||
|
'require_subscription' => 1,
|
||||||
|
], '');
|
||||||
|
}
|
||||||
|
|
||||||
|
$jumpUrl = \App\Support\BackUrl::withBack($jumpBase, $createSelfForBack);
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
@if(($requireSubscription ?? false) && $jumpUrl)
|
@if(($requireSubscription ?? false) && $jumpUrl)
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminPlatformOrderCreateRequireSubscriptionFlagJumpBackShouldIncludeRequireSubscriptionTest 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_jump_to_subscriptions_link_should_carry_back_with_require_subscription_flag_when_no_query(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
// 模拟“校验失败回填后”回到 create 页:URL 不带 require_subscription query,但 old input 仍有 require_subscription=1
|
||||||
|
// 通过 withSession 注入 old input
|
||||||
|
$res = $this->withSession([
|
||||||
|
'_old_input' => [
|
||||||
|
'require_subscription' => '1',
|
||||||
|
],
|
||||||
|
])->get('/admin/platform-orders/create');
|
||||||
|
|
||||||
|
$res->assertOk();
|
||||||
|
|
||||||
|
// 关键:跳转订阅管理的链接应带 back,且 back 中应包含 require_subscription=1
|
||||||
|
// 这样用户从订阅管理选中订阅再回来,治理口径不会丢。
|
||||||
|
$res->assertSee('去订阅管理选择订阅', false);
|
||||||
|
$res->assertSee('back=%2Fadmin%2Fplatform-orders%2Fcreate%3Frequire_subscription%3D1', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user