From c4f96a7185b18c445f23410d34084b15140f3155 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Sun, 4 Oct 2026 12:42:17 +0200 Subject: [PATCH] fix(analytics): label zero response status in traffic breakdowns --- .../traffic/_breakdown-section.blade.php | 1 + .../AnalyticsFormattingTest.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/resources/views/livewire/traffic/_breakdown-section.blade.php b/resources/views/livewire/traffic/_breakdown-section.blade.php index d854f4e924..e6b1e9be4f 100644 --- a/resources/views/livewire/traffic/_breakdown-section.blade.php +++ b/resources/views/livewire/traffic/_breakdown-section.blade.php @@ -31,6 +31,7 @@ : match ($dimension) { 'device' => deviceLabel($value), 'referer' => $host ?? 'Direct / none', + 'status' => $value === '0' ? 'No response status (0)' : ($value !== '' ? $value : 'Unknown'), default => $value !== '' ? $value : 'Unknown', }; $requests = (int) ($row['requests'] ?? 0); diff --git a/tests/Feature/TrafficAnalytics/AnalyticsFormattingTest.php b/tests/Feature/TrafficAnalytics/AnalyticsFormattingTest.php index 2401622624..54fd736d6f 100644 --- a/tests/Feature/TrafficAnalytics/AnalyticsFormattingTest.php +++ b/tests/Feature/TrafficAnalytics/AnalyticsFormattingTest.php @@ -55,3 +55,21 @@ it('renders ampersands in breakdown empty-state descriptions', function () { ->toContain('No ai agents & bots data for the selected range.') ->not->toContain('No ai agents &amp; bots data for the selected range.'); }); + +it('distinguishes a missing response status from numeric values in other dimensions', function (string $dimension, mixed $value, string $display) { + $html = view('livewire.traffic._breakdown-section', [ + 'dimension' => $dimension, + 'label' => 'Breakdown', + 'rows' => [['value' => $value, 'requests' => 2, 'bytesOut' => 0]], + ])->render(); + + expect($html)->toContain('title="'.$display.'"') + ->toContain('title="2 requests"'); +})->with([ + 'integer zero status' => ['status', 0, 'No response status (0)'], + 'string zero status' => ['status', '0', 'No response status (0)'], + 'valid status' => ['status', '200', '200'], + 'missing status' => ['status', '', 'Unknown'], + 'overflow status' => ['status', '__other__', 'Other'], + 'zero in another dimension' => ['path', '0', '0'], +]);