test: add Next.js head change e2e coverage#10
Merged
Conversation
Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
There was a problem hiding this comment.
Code Review
This pull request refactors the E2E test suite by extracting the Monaco mock into a shared fixture and introduces a new test case and page to verify that Monaco stylesheets are preserved during Next.js Head updates. Feedback was provided to optimize the stylesheet injection logic in the new test page by updating the global flag when a stylesheet is already present, thereby avoiding redundant DOM queries.
Comment on lines
+64
to
+65
| if (globalThis.__issue272StylesheetInjected) return; | ||
| if (document.querySelector('link[data-name="vs/editor/editor.main"]')) return; |
There was a problem hiding this comment.
To avoid redundant DOM queries on every render, the global flag should be updated if the stylesheet is already present in the document. This aligns with the goal of simplifying code and eliminating redundancy (Repository Style Guide, Rule 6).
Suggested change
| if (globalThis.__issue272StylesheetInjected) return; | |
| if (document.querySelector('link[data-name="vs/editor/editor.main"]')) return; | |
| if (globalThis.__issue272StylesheetInjected || document.querySelector('link[data-name="vs/editor/editor.main"]')) { | |
| globalThis.__issue272StylesheetInjected = true; | |
| return; | |
| } |
References
- Simplify code as much as possible to eliminate redundancy. (link)
Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
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.
Related to suren-atoyan#272
Summary
next/headwhile remounting the editor.vs/editor/editor.main.cssstylesheet remains present across repeated head changes.Why
Testing
yarn check-for-aiyarn test:e2e:next