Fix/service worker installation#76
Merged
Merged
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request introduces improvements to the mock service worker infrastructure, focusing on version management, file extension handling, and test coverage. The main goals are to ensure smoother service worker updates, improve file-matching robustness (especially with query parameters), and provide more reliable and comprehensive testing.
Key changes include:
Service Worker Version Management
Introduced a
TWD_VERSIONconstant to centralize the version number for the mock service worker and ensure consistent versioning across the codebase. Service worker registration now includes the version in the query string, and localStorage is used to track and update the service worker version as needed. Old service workers are unregistered when a version change is detected, and the code waits for the service worker to take control before proceeding. (src/constants/version.js,src/constants/version.ts,src/commands/mockBridge.ts,src/cli/mock-sw.js, [1] [2] [3] [4] [5] [6] [7]The service worker now logs its version dynamically using the new constant, and the install/activate lifecycle events are handled to ensure immediate activation and control. (
src/cli/mock-sw.js, src/cli/mock-sw.jsR85-R94)Improved File Extension Handling
/api.twd.test.ts?t=12345), ensuring that file matching works correctly even when query strings are present. This change is reflected in both the main code and the distributed service worker files. (src/cli/utils/findRule.js,examples/tutorial-example/public/mock-sw.js,examples/twd-test-app/public/mock-sw.js, [1] [2]Test Enhancements
src/tests/commands/mockBridge/initMocking.spec.ts,src/tests/cli/findRule.spec.js, [1] [2] [3] [4] [5]Documentation/Deployment
.github/workflows/deploy_docs.yml, .github/workflows/deploy_docs.ymlL53-R53)This closes #74