Fixes #3817 Correct rounding and carry of minutes in client/plugins/utils.js::$elapsedPrettyExtended #3832
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Correct rounding and carry of minutes in client/plugins/utils.js:: Vue.prototype.$elapsedPrettyExtended
-Add cypress tests for Vue.prototype.$elapsedPrettyExtended function
Note: This is my first PR to the project, any feedback would be appreciated.
Brief summary
In the Audiobookshelf Year In Review, there was a time at which the App reported
"Listening Time" as "44d23h60m", but it should have been "Listening Time" as "45d"
Which issue is fixed?
Fixes #3817
In-depth Description
In client/plugins/utils.js:: Vue.prototype.$elapsedPrettyExtended,
specifically when showSeconds=false, the code to round minutes up (when seconds>=30) did not account for the carry of minutes into hours.
The solution was to add a condition that if the rounded up minutes were now>=60, we should carry minutes into hours.
Furthermore, this rounding condition was moved up in the function, before the conditional days handling, to prevent this carry condition from needing to be propagated to days as well.
How have you tested this?
I have added cypress tests (although these are pure functional/non-UI tests) to validate the current behavior of the
$elapsedPrettyExtended
function.Given that the current (existing) cypress tests are not all passing, and do not seem to be run in any GitHub Action CI tasks,
this is how you can run only the newly contributed tests:
Test Results
I also ran a brute force test (not submitted) to guarantee that the corrected function did not change the function's behaviour for cases other than those identified in this bug fix. i.e. I compared the value of the original function vs the fixed version for all values of 'seconds' in
[0s, 101 days]
in increments of0.5
secondsScreenshots
None