card dashboard produksi
This commit is contained in:
@@ -106,3 +106,24 @@ test('actual productivity rounds kg per hectare to two decimals', function () {
|
||||
|
||||
expect(($this->chart)()['series'][1])->toBe(33.33);
|
||||
});
|
||||
|
||||
test('productivity cards display the same values and commodities as the chart', function () {
|
||||
DB::table('map_lahan')->where('petani_id', 5)->update(['luas_lahan' => 0.3]);
|
||||
$controller = app(SummaryController::class);
|
||||
$method = new ReflectionMethod($controller, 'productivityKpiCards');
|
||||
|
||||
foreach ([[], ['desaKelurahan_id' => 2], ['komoditas_id' => 1]] as $filters) {
|
||||
$chart = ($this->chart)($filters);
|
||||
$cards = $method->invoke($controller, $chart);
|
||||
|
||||
expect(array_column($cards, 'label'))->toBe(array_map(
|
||||
fn ($name) => 'Produktivitas Aktual '.$name,
|
||||
$chart['labels'],
|
||||
));
|
||||
expect(array_column($cards, 'value'))->toBe(array_map(
|
||||
fn ($value) => number_format($value, 2, ',', '.'),
|
||||
$chart['series'],
|
||||
));
|
||||
expect(array_column($cards, 'unit'))->toBe(array_fill(0, count($chart['labels']), 'kg/ha'));
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user