Fix manifest cache for local JavaScript feature tests#10365
Merged
Conversation
changelog: Internal, Automated Testing, Fix manifest cache for local JavaScript feature tests
aduth
commented
Apr 4, 2024
| # rubocop:enable Style/GlobalVars | ||
| # rubocop:disable Rails/Output | ||
| print ' Bundling JavaScript and stylesheets... ' | ||
| system 'WEBPACK_PORT= yarn concurrently "yarn:build:*" > /dev/null 2>&1' |
Contributor
Author
There was a problem hiding this comment.
Removing the environment variable isn't related to the fix, but was part of my troubleshooting. I don't think it's doing anything since the value is "empty" regardless whether it's provided or not.
mitchellhenke
approved these changes
Apr 4, 2024
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.
🛠 Summary of changes
Ensures that the JavaScript build which runs when executing a test using the JavaScript driver in tests will invalidate the cached assets manifest.
This resolves an issue where running JavaScript feature specs locally could result in Content-Security-Policy errors in trying to load scripts from http://localhost:3035/ (the Webpack dev server).
This may have been made more prevalent by recent changes in #10301 to eagerly cache the manifest, though likely existed prior.
As outlined in the included inline code comment, the problem is that the application will cache whatever manifest exists at startup, but the JavaScript build happens on-demand. Therefore, the application may try to load incorrect URLs if the on-demand build would produce a different manifest.
📜 Testing Plan
make run. This will generatepublic/packs/manifest.jsonwith http://localhost:3035/ URLs for the Webpack dev serverrspec ./spec/features/accessibility/idv_pages_spec.rb:20Before: You would see CSP errors, because the application starts up and caches the manifest produced by Step 1 .
Example:
After: The test will pass, because the cached manifest will be reloaded using the manifest generated by the on-demand JavaScript build.