Repository navigation
EditPostPreferencesModal: fix intermittently failing tests - #53814
Conversation
| useViewportMatch.mockImplementation( () => false ); | ||
| render( <EditPostPreferencesModal /> ); | ||
| expect( | ||
| await screen.findByRole( 'dialog', { name: 'Preferences' } ) |
There was a problem hiding this comment.
For small viewports, the modal uses the Navigator* components instead of TabPanel. The UI is completely synchronous, and the test doesn't need to await.
|
Size Change: 0 B Total Size: 1.51 MB ℹ️ View Unchanged
|
|
I've noticed this test still appears to fail intermittently on PRs. To reproduce, if I run the following locally on
Would it be worth us trying to add in a tiny delay to compensate for the |
|
Removing
This seems like a good option to me. Just looking at the component, do we really need a snapshot to check that the viewport rendering works? Seems like we could test for visibility on a few of the main elements. |
I've done that here just in case folks agree: |

Fixes unit tests that started failing randomly since #52133. See #52133 (comment) for details.
The fix makes sure that we wait until the default tab (General) is selected, before comparing rendered markup with the snapshot.
The selection is not done on initial render, but is delayed until some effects and rAFs are flushed. The symptoms is that
tabindexand sometimes alsodata-active-itemattributes on the<button role="tab">elements don't match.It can be tracked down to Ariakit's
useCompositeItemhook, where theisTabbablevalue takes some time to settle on the expected value.