93 lines
3.5 KiB
PHP
93 lines
3.5 KiB
PHP
<?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 AdminPlatformBatchShowPageSpotCheckEmptyStateShouldNotRenderActionButtonsTest 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_batch_show_page_spot_check_empty_state_should_not_render_action_buttons_when_no_success_sample(): void
|
|
{
|
|
$this->loginAsPlatformAdmin();
|
|
|
|
$merchant = Merchant::query()->firstOrFail();
|
|
$plan = Plan::query()->create([
|
|
'code' => 'plan_batch_spot_empty_actions_0001',
|
|
'name' => '批次页抽样复核空态动作护栏测试套餐',
|
|
'billing_cycle' => 'monthly',
|
|
'price' => 10,
|
|
'list_price' => 10,
|
|
'status' => 'active',
|
|
'sort' => 10,
|
|
'published_at' => now(),
|
|
]);
|
|
|
|
$runId = 'BMPA_SPOT_EMPTY_ACTIONS_0001';
|
|
|
|
PlatformOrder::query()->create([
|
|
'merchant_id' => $merchant->id,
|
|
'plan_id' => $plan->id,
|
|
'order_no' => 'PO_BMPA_SPOT_EMPTY_ACTIONS_0001',
|
|
'order_type' => 'new_purchase',
|
|
'status' => 'pending',
|
|
'payment_status' => 'paid',
|
|
'plan_name' => $plan->name,
|
|
'billing_cycle' => $plan->billing_cycle,
|
|
'period_months' => 1,
|
|
'quantity' => 1,
|
|
'payable_amount' => 10,
|
|
'paid_amount' => 10,
|
|
'placed_at' => now()->subMinutes(10),
|
|
'paid_at' => now()->subMinutes(9),
|
|
'meta' => [
|
|
'batch_mark_paid_and_activate' => [
|
|
'run_id' => $runId,
|
|
'last_result' => [
|
|
'run_id' => $runId,
|
|
'success' => 0,
|
|
'failed' => 1,
|
|
'matched' => 1,
|
|
'processed' => 1,
|
|
'top_reasons' => [
|
|
['reason' => '模拟失败:无成功样本', 'count' => 1],
|
|
],
|
|
'at' => now()->toDateTimeString(),
|
|
],
|
|
],
|
|
'batch_mark_paid_and_activate_error' => [
|
|
'message' => '模拟失败:无成功样本',
|
|
'at' => now()->toDateTimeString(),
|
|
],
|
|
],
|
|
]);
|
|
|
|
$html = $this->get('/admin/platform-batches/show?type=bmpa&run_id=' . $runId)
|
|
->assertOk()
|
|
->getContent();
|
|
|
|
$this->assertStringContainsString('data-role="platform-batch-spot-check"', $html);
|
|
$this->assertStringContainsString('暂无可抽样订单(可能暂无成功单,或 last_result 尚未补齐)。', $html);
|
|
$this->assertStringNotContainsString('data-role="batch-spot-check-link"', $html);
|
|
$this->assertStringNotContainsString('data-role="copy-spot-check-link"', $html);
|
|
$this->assertStringNotContainsString('data-role="copy-spot-check-order-id"', $html);
|
|
$this->assertStringNotContainsString('data-role="copy-spot-check-run-id"', $html);
|
|
$this->assertStringNotContainsString('data-role="batch-spot-check-next"', $html);
|
|
}
|
|
}
|