Files
saasshop/tests/Feature/AdminDashboardPlanOrderShareMiniChartShouldNormalizeBarWidthByTopMaxTest.php

23 lines
996 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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);
}
}