fix(analytics): label zero response status in traffic breakdowns

This commit is contained in:
Andras Bacsai
2026-10-04 12:42:17 +02:00
parent 15b64d6c56
commit c4f96a7185
2 changed files with 19 additions and 0 deletions
@@ -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);
@@ -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 & 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'],
]);