Tests: ensure dashboard mini bar rows link to correct governance scopes

This commit is contained in:
萝卜
2026-03-17 02:26:46 +08:00
parent 6fec201db0
commit dcf83121bf

View File

@@ -0,0 +1,47 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminDashboardMiniBarRowsShouldLinkToGovernanceScopesTest 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_dashboard_mini_bar_rows_should_link_to_expected_scopes_with_safe_back(): void
{
$this->loginAsPlatformAdmin();
$res = $this->get('/admin');
$res->assertOk();
$html = (string) $res->getContent();
// 行可点击(漏斗 + 治理)
$this->assertStringContainsString('adm-mini-bar-row-link', $html);
// 漏斗:待支付 / 待生效 / 可同步
$this->assertStringContainsString('href="/admin/platform-orders?payment_status=unpaid&status=pending&back=%2Fadmin"', $html);
$this->assertStringContainsString('href="/admin/platform-orders?payment_status=paid&status=pending&sync_status=unsynced&back=%2Fadmin"', $html);
$this->assertStringContainsString('href="/admin/platform-orders?syncable_only=1&sync_status=unsynced&back=%2Fadmin"', $html);
// 治理:同步失败 / 无回执 / 续费缺订阅
$this->assertStringContainsString('href="/admin/platform-orders?sync_status=failed&back=%2Fadmin"', $html);
$this->assertStringContainsString('href="/admin/platform-orders?payment_status=paid&receipt_status=none&back=%2Fadmin"', $html);
$this->assertStringContainsString('href="/admin/platform-orders?renewal_missing_subscription=1&back=%2Fadmin"', $html);
// back 参数不得被 Blade escape 成 &amp;back避免 nested back/可读性问题)
$this->assertStringNotContainsString('&amp;back=', $html);
}
}