forked from jywarren/image-sequencer
-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed registration problem of service worker #1807
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
178d8ef
fixed registration problem of service worker
vivek-30 b43f2d2
Merge branch 'main' into registration
jywarren e8be77f
added a test for service worker
vivek-30 ce75c2e
Merge branch 'main' into registration
jywarren 835b60f
reused some existing code to avoid code duplication
vivek-30 1b29ddf
Merge branch 'registration' of https://github.com/vivek-30/image-sequ…
vivek-30 bcf1e12
Merge branch 'main' into registration
jywarren File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
var setUpCache = new require('../../../examples/lib/cache')(); | ||
var test = require('tape'); | ||
|
||
function SWInstallation(){ | ||
return new Promise(() => { | ||
return setupCache(); | ||
}); | ||
} | ||
|
||
function UnRegisterSW(){ | ||
|
||
function unregister() { | ||
return navigator.serviceWorker.getRegistrations() | ||
.then(function(registrations) { | ||
var unRegisteredWorker = registrations.map(function(registration) { | ||
return registration.unregister(); | ||
}); | ||
return Promise.all(unRegisteredWorker); | ||
}); | ||
} | ||
|
||
return Promise.all([ | ||
unregister(), | ||
setUpCache.clearCache() | ||
]); | ||
} | ||
|
||
test('Register service worker',function(t) { | ||
|
||
t.test('unregister service worker',function(st) { | ||
st.equal(UnRegisterSW(),true,'unregistered successfully and cleared the cache') | ||
}) | ||
|
||
t.test('install service worker',function(st) { | ||
st.equal(SWInstallation(),true,'successfully installed new service worker') | ||
}); | ||
}); |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is happening bcoz we have already checked service worker state as installed and now this state
installing
will not come again. so it returns a null on which we have just added astatechange
event listener which is meaningless.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thank you!; this is so hard to track as maintainers; do you think it's possible to write a test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried to write test for this but i don't know how to make this run 😅 ?
you can have a look this test -
https://github.com/vivek-30/image-sequencer/blob/5fc7fc8ecbb02ac989605a4d422b7b8d85d67aeb/test/core/sw.test.js#L1-L72
@jywarren, @harshkhandeparkar could you please suggest me what to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually @jywarren what i think is even if we don't build a test for this then also it will solve this problem.
No doubt that adding test will ensure more security and safety but don't think it will slow down image sequencer as to check a successful installation of sw .we have to remove existing sw and clear out the cache and then register a new updated sw (which i have done in my test) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for giving it a try! If you add the test to the correct folder alongside others in this repo, it'll run within this PR. It's possible you need to add some more assertions -- like, see how this line confirms something we expect to be true about the test scenario:
image-sequencer/test/core/sequencer/chain.js
Line 16 in eb81b7d
Want to try adding your test in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jywarren plz have a look now ,i have added a test for this. Hope you like it☺️