-
-
Notifications
You must be signed in to change notification settings - Fork 638
Only initiate hydration after all subresources loaded #1988
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
Changes from 1 commit
c63c292
497c5d1
aaae2d0
de4d34b
23866f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,23 +78,23 @@ describe('pageLifecycle', () => { | |
| // Since no navigation library is mocked, callbacks should run immediately | ||
| expect(callback).toHaveBeenCalledTimes(1); | ||
| // Should not add DOMContentLoaded listener since readyState is not 'loading' | ||
| expect(addEventListenerSpy).not.toHaveBeenCalledWith('DOMContentLoaded', expect.any(Function)); | ||
| expect(addEventListenerSpy).not.toHaveBeenCalledWith('readystatechange', expect.any(Function)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Update outdated terminology to reflect 'load' event usage. The test descriptions and comments reference "readystatechange" but the implementation now uses the
After fixing the production bug to use - expect(addEventListenerSpy).toHaveBeenCalledWith('load', expect.any(Function));
+ expect(addEventListenerSpy.window).toHaveBeenCalledWith('load', expect.any(Function));Also applies to: 84-84, 91-94, 97-97, 106-107 |
||
| }); | ||
|
|
||
| it('should initialize page event listeners immediately when document.readyState is "interactive"', () => { | ||
| setReadyState('interactive'); | ||
| it('should wait for readystatechange when document.readyState is "interactive"', () => { | ||
| setReadyState('loading'); | ||
| const callback = jest.fn(); | ||
| const { onPageLoaded } = importPageLifecycle(); | ||
|
|
||
| onPageLoaded(callback); | ||
|
|
||
| // Since no navigation library is mocked, callbacks should run immediately | ||
| expect(callback).toHaveBeenCalledTimes(1); | ||
| // Should not add DOMContentLoaded listener since readyState is not 'loading' | ||
| expect(addEventListenerSpy).not.toHaveBeenCalledWith('DOMContentLoaded', expect.any(Function)); | ||
| // Should not call callback immediately since readyState is 'loading' | ||
| expect(callback).not.toHaveBeenCalled(); | ||
| // Verify that a DOMContentLoaded listener was added when readyState is 'loading' | ||
| expect(addEventListenerSpy).toHaveBeenCalledWith('load', expect.any(Function)); | ||
| }); | ||
|
|
||
| it('should wait for DOMContentLoaded when document.readyState is "loading"', () => { | ||
| it('should wait for readystatechange when document.readyState is "loading"', () => { | ||
| setReadyState('loading'); | ||
| const callback = jest.fn(); | ||
| const { onPageLoaded } = importPageLifecycle(); | ||
|
|
@@ -104,7 +104,7 @@ describe('pageLifecycle', () => { | |
| // Should not call callback immediately since readyState is 'loading' | ||
| expect(callback).not.toHaveBeenCalled(); | ||
| // Verify that a DOMContentLoaded listener was added when readyState is 'loading' | ||
| expect(addEventListenerSpy).toHaveBeenCalledWith('DOMContentLoaded', expect.any(Function)); | ||
| expect(addEventListenerSpy).toHaveBeenCalledWith('load', expect.any(Function)); | ||
| }); | ||
|
|
||
| describe('with Turbo navigation library', () => { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.