补齐批次详情页访客与空态边界测试

This commit is contained in:
萝卜
2026-03-20 09:58:37 +08:00
parent 9b46699ed7
commit 9cf2e7d8e4
3 changed files with 75 additions and 1 deletions

View File

@@ -0,0 +1,19 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformBatchShowPageGuestCannotAccessTest extends TestCase
{
use RefreshDatabase;
public function test_guest_cannot_access_platform_batch_show_page(): void
{
$this->seed();
$this->get('/admin/platform-batches/show?type=bas&run_id=BAS_GUEST_0001')
->assertRedirect('/admin/login');
}
}

View File

@@ -0,0 +1,55 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformBatchShowPageInvalidTypeAndEmptyStateTest 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_batch_show_page_should_render_error_when_type_is_invalid(): void
{
$this->loginAsPlatformAdmin();
$html = $this->get('/admin/platform-batches/show?type=unknown&run_id=RUN_INVALID_TYPE_0001')
->assertOk()
->getContent();
$this->assertStringContainsString('参数不完整:请提供 typebas/bmpa与 run_id。', $html);
$this->assertStringContainsString('href="/admin/platform-orders"', $html);
$this->assertStringNotContainsString('data-action="copy-run-id"', $html);
$this->assertStringNotContainsString('data-role="batch-spot-check-link"', $html);
}
public function test_platform_batch_show_page_should_render_empty_batch_zero_state_when_run_id_has_no_orders(): void
{
$this->loginAsPlatformAdmin();
$html = $this->get('/admin/platform-batches/show?type=bas&run_id=BAS_EMPTY_0001')
->assertOk()
->getContent();
$this->assertStringContainsString('BAS批量同步订阅 批次详情', $html);
$this->assertStringContainsString('run_id<strong>BAS_EMPTY_0001</strong>', $html);
$this->assertStringContainsString('本批次尚未生成 last_result 汇总', $html);
$this->assertStringContainsString('data-role="batch-matched-link"', $html);
$this->assertStringContainsString('>0</a>', $html);
$this->assertStringContainsString('暂无可抽样订单(可能暂无成功单,或 last_result 尚未补齐)。', $html);
$this->assertStringContainsString('Top 失败原因', $html);
$this->assertStringContainsString('暂无last_result 未写入时不做原因聚合,以免在页面侧引入重查询)。', $html);
$this->assertStringContainsString('batch_activation_run_id=BAS_EMPTY_0001', $html);
$this->assertStringNotContainsString('data-role="batch-failed-ratio-link"', $html);
}
}