From f2f7899fe8f2dc0687c005182336edd589e70e84 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Thu, 2 Jan 2025 16:23:51 +0100 Subject: [PATCH] Ensure non-bot values are printed if value is zero --- CHANGELOG.md | 17 +++++++++++++++++ src/overview/helpers/VisitsHighlightCard.tsx | 2 +- .../helpers/VisitsHighlightCard.test.tsx | 4 ++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58c4cb9f..ed0d6294 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org). +## [Unreleased] +### Added +* *Nothing* + +### Changed +* *Nothing* + +### Deprecated +* *Nothing* + +### Removed +* *Nothing* + +### Fixed +* Fix bots visits displayed in overview cards even if bots are excluded, if the amount of non-bot visits is zero. + + ## [0.12.0] - 2024-12-05 ### Added * *Nothing* diff --git a/src/overview/helpers/VisitsHighlightCard.tsx b/src/overview/helpers/VisitsHighlightCard.tsx index 6da51057..ebcbd9e7 100644 --- a/src/overview/helpers/VisitsHighlightCard.tsx +++ b/src/overview/helpers/VisitsHighlightCard.tsx @@ -20,7 +20,7 @@ export const VisitsHighlightCard: FC = ({ loading, exc {...rest} > {loading ? 'Loading...' : prettify( - excludeBots && visitsSummary.nonBots ? visitsSummary.nonBots : visitsSummary.total, + excludeBots && visitsSummary.nonBots !== undefined ? visitsSummary.nonBots : visitsSummary.total, )} ); diff --git a/test/overview/helpers/VisitsHighlightCard.test.tsx b/test/overview/helpers/VisitsHighlightCard.test.tsx index 07873782..fd5461ea 100644 --- a/test/overview/helpers/VisitsHighlightCard.test.tsx +++ b/test/overview/helpers/VisitsHighlightCard.test.tsx @@ -51,6 +51,10 @@ describe('', () => { expect(screen.getByText('20')).toBeInTheDocument(); expect(screen.queryByText('50')).not.toBeInTheDocument(); }], + [true, 0, () => { + expect(screen.getByText('0')).toBeInTheDocument(); + expect(screen.queryByText('50')).not.toBeInTheDocument(); + }], [true, undefined, () => { expect(screen.getByText('50')).toBeInTheDocument(); expect(screen.queryByText('20')).not.toBeInTheDocument();