feat(admin-dashboard): normalize plan share bar widths by top max
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user