🐛 ✅ Fix caching for "Dismiss this Version" in pulsar-updater #785
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.
Identify the Bug
#784
Description of the Change
I found that the code was expecting the local storage key to keep the last-update-check value in cache ifinitely, but it was not provided as an argument, so I added it.
Then I looked into the tests and extended them to cover the fix as well. I added a dummy key to all
isItemExpired
call to reflect on how the code should work.While I was adding and fixing theses tests, I found that they produced false positive results because the tests were using fake timers,
Date.now()
was always 1000 which meant that all cache-tests produced a non-expired cache entry. I set jasmine to usejasmine.useRealClock();
Then, there's the last test: it meant to mock out the
online()
method which was required from the other file into acache
object. However, this method on thecache
is not the same as the one called from theisItemExpired()
method from jasmine's perspective, hence the mock wasn't working - see the false positive results. The proper way to check this behaviour would be to mock outwindow.navigator
'sonLine
property, however, Pulsar is using an old and unmaintained implementation of the jasmine test-framework which doesn't support this feature yet. I wrote how the test should look like and moved it behind a condition, we'll run this only with more recent jasmine version.Alternate Designs
Possible Drawbacks
Verification Process
I've run the new tests on the package.
Release Notes