Files
saasshop/tests/Feature/AdminPlatformOrderIndexBatchFormsShouldDisableOnSubmitTest.php

42 lines
1.5 KiB
PHP

<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformOrderIndexBatchFormsShouldDisableOnSubmitTest 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_platform_order_index_batch_forms_should_disable_on_submit(): void
{
$this->loginAsPlatformAdmin();
$res = $this->get('/admin/platform-orders');
$res->assertOk();
$html = (string) $res->getContent();
// 高风险批量动作:必须带 data-action="disable-on-submit",避免运营重复点击造成重复请求。
$this->assertStringContainsString('action="/admin/platform-orders/batch-activate-subscriptions"', $html);
$this->assertStringContainsString('action="/admin/platform-orders/batch-mark-paid-and-activate"', $html);
$this->assertStringContainsString('action="/admin/platform-orders/batch-mark-activated"', $html);
$this->assertStringContainsString('action="/admin/platform-orders/clear-sync-errors"', $html);
$this->assertStringContainsString('action="/admin/platform-orders/clear-bmpa-errors"', $html);
// 至少出现多次(每个工具组含 filtered/all 两套表单)
$this->assertTrue(substr_count($html, 'data-action="disable-on-submit"') >= 6);
}
}