Ensure that calculateChange()
returns zero when both current and previous values are zero.
#7172
Labels
calculateChange()
returns zero when both current and previous values are zero.
#7172
Feature Description
At the moment, the
calculateChange()
function returnsnull
when theprevious
value is zero, as seen here:site-kit-wp/assets/js/util/index.js
Lines 87 to 91 in 100ca94
However, this is incorrect in the scenario where
current
is also zero, in which case the change should be returned as0
rather thannull
.This was identified as a fix for a point raised in QA for #6244 (see "Question 2" here), but appears to be a valid fix to make across the board for
calculateChange()
. However, with this function being used widely in the codebase, due diligence must be applied to confirm this is the case and validate with a good round of testing.Note: There is a closed PR which can be recreated as the fix for this assuming it's confirmed as above.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
ChangeBadge
rendered in Key Metric Widgets should show 0% where both, the previous and current values are 0.Implementation Brief
calculateChange()
function should return 0 when both theprevious
andcurrent
values are zero.Test Coverage
QA Brief
Changelog entry
The text was updated successfully, but these errors were encountered: