feat(admin): 订单详情绑定订阅表单防重复提交

This commit is contained in:
萝卜
2026-03-15 17:35:29 +08:00
parent dbe90c1703
commit b2fe4abbac
2 changed files with 67 additions and 1 deletions

View File

@@ -0,0 +1,66 @@
<?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 AdminPlatformOrderShowAttachSubscriptionFormShouldDisableOnSubmitTest 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_attach_subscription_form_should_have_disable_on_submit_marker(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'po_show_attach_form_disable_plan',
'name' => '订单详情绑定订阅表单防重复提交测试套餐',
'billing_cycle' => 'monthly',
'price' => 30,
'list_price' => 30,
'status' => 'active',
'sort' => 10,
'published_at' => now(),
]);
$order = PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_SHOW_ATTACH_FORM_DISABLE_0001',
'order_type' => 'renewal',
'status' => 'pending',
'payment_status' => 'unpaid',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'quantity' => 1,
'payable_amount' => 30,
'paid_amount' => 0,
'placed_at' => now(),
'meta' => [],
]);
$res = $this->get('/admin/platform-orders/' . $order->id);
$res->assertOk();
$html = (string) $res->getContent();
$this->assertStringContainsString('/admin/platform-orders/' . $order->id . '/attach-subscription', $html);
$this->assertStringContainsString('data-action="disable-on-submit"', $html);
}
}