ui(site-subscriptions): disable-on-submit for set-status form on show
This commit is contained in:
@@ -73,7 +73,7 @@
|
||||
<div class="muted">状态</div>
|
||||
<div class="num-md">{{ ($statusLabels[$subscription->status] ?? $subscription->status) }} <span class="muted">({{ $subscription->status }})</span></div>
|
||||
<div class="mt-6">
|
||||
<form method="post" action="/admin/site-subscriptions/{{ $subscription->id }}/set-status" class="actions gap-10">
|
||||
<form method="post" action="/admin/site-subscriptions/{{ $subscription->id }}/set-status" class="actions gap-10" data-action="disable-on-submit">
|
||||
@csrf
|
||||
<select name="status" onchange="this.form.submit()" class="w-140">
|
||||
@foreach(($statusLabels ?? []) as $value => $label)
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\Merchant;
|
||||
use App\Models\SiteSubscription;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminSiteSubscriptionShowSetStatusFormShouldDisableOnSubmitTest 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_show_set_status_form_should_disable_on_submit(): void
|
||||
{
|
||||
$this->loginAsPlatformAdmin();
|
||||
|
||||
$merchant = Merchant::query()->firstOrFail();
|
||||
|
||||
$sub = SiteSubscription::query()->create([
|
||||
'merchant_id' => $merchant->id,
|
||||
'status' => 'pending',
|
||||
'source' => 'manual',
|
||||
'subscription_no' => 'SUB_SHOW_SET_STATUS_DISABLE_0001',
|
||||
'plan_name' => '测试套餐',
|
||||
'billing_cycle' => 'monthly',
|
||||
'period_months' => 1,
|
||||
'amount' => 10,
|
||||
'starts_at' => now()->subDay(),
|
||||
'ends_at' => now()->addDays(29),
|
||||
]);
|
||||
|
||||
$res = $this->get('/admin/site-subscriptions/' . $sub->id);
|
||||
$res->assertOk();
|
||||
|
||||
$res->assertSee('action="/admin/site-subscriptions/' . $sub->id . '/set-status"', false);
|
||||
$res->assertSee('data-action="disable-on-submit"', false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user