feat(admin-dashboard): normalize plan share bar widths by top max

This commit is contained in:
萝卜
2026-03-16 14:59:30 +08:00
parent 9852d9b00e
commit 90794f9b5e
2 changed files with 37 additions and 2 deletions

View File

@@ -0,0 +1,22 @@
<?php
namespace Tests\Feature;
use Tests\TestCase;
class AdminDashboardPlanOrderShareMiniChartShouldNormalizeBarWidthByTopMaxTest extends TestCase
{
public function test_dashboard_plan_order_share_mini_chart_should_normalize_bar_width_by_top_max(): void
{
$js = (string) file_get_contents(public_path('js/admin.js'));
// 护栏:占比条形图 bar 宽度应按 Top5 最大单量归一(而不是按 total 分母),避免“覆盖率低时所有 bar 很短难看”。
$this->assertStringContainsString('var maxCnt = 0', $js);
$this->assertStringContainsString('maxCnt = v', $js);
$this->assertStringContainsString('var barRatio =', $js);
$this->assertStringContainsString("bar.style.width = Math.round(barRatio * 100) + '%'", $js);
// 百分比展示仍必须按 total 分母ratio不能被 barRatio 替代。
$this->assertStringContainsString("val.textContent = formatPct(ratio, 1) + '%'", $js);
}
}