test(platform-orders): guardrail no-receipt fix link anchors to receipt panel

This commit is contained in:
萝卜
2026-03-17 08:14:50 +08:00
parent 96ea53a6db
commit 1d0e32e41d

View File

@@ -0,0 +1,54 @@
<?php
namespace Tests\Feature;
use App\Models\Merchant;
use App\Models\PlatformOrder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformOrderIndexNoReceiptFixLinkShouldPointToAddPaymentReceiptPanelTest 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_index_no_receipt_fix_link_should_point_to_add_payment_receipt_panel(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$order = PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => null,
'site_subscription_id' => null,
'order_no' => 'PO_INDEX_NO_RECEIPT_FIX_LINK',
'order_type' => 'new_purchase',
'status' => 'pending',
'payment_status' => 'paid',
'payable_amount' => 10,
'paid_amount' => 10,
'paid_at' => now(),
'meta' => [], // 无 payment_receipts / payment_summary
]);
$res = $this->get('/admin/platform-orders');
$res->assertOk();
$html = (string) $res->getContent();
// 无回执行应提供“去补回执”入口,且锚点必须为 #add-payment-receipt避免误跳到其它 section
$this->assertStringContainsString('无回执', $html);
$this->assertStringContainsString('/admin/platform-orders/' . $order->id, $html);
$this->assertStringContainsString('#add-payment-receipt', $html);
}
}