@@ -17,8 +17,10 @@ describe('Store', () => {
1717 let act ;
1818 let actAsync ;
1919 let bridge ;
20+ let createDisplayNameFilter ;
2021 let getRendererID ;
2122 let legacyRender ;
23+ let previousComponentFilters ;
2224 let store ;
2325 let withErrorsOrWarningsIgnored ;
2426
@@ -29,6 +31,8 @@ describe('Store', () => {
2931 bridge = global . bridge ;
3032 store = global . store ;
3133
34+ previousComponentFilters = store . componentFilters ;
35+
3236 React = require ( 'react' ) ;
3337 ReactDOM = require ( 'react-dom' ) ;
3438 ReactDOMClient = require ( 'react-dom/client' ) ;
@@ -38,9 +42,14 @@ describe('Store', () => {
3842 actAsync = utils . actAsync ;
3943 getRendererID = utils . getRendererID ;
4044 legacyRender = utils . legacyRender ;
45+ createDisplayNameFilter = utils . createDisplayNameFilter ;
4146 withErrorsOrWarningsIgnored = utils . withErrorsOrWarningsIgnored ;
4247 } ) ;
4348
49+ afterEach ( ( ) => {
50+ store . componentFilters = previousComponentFilters ;
51+ } ) ;
52+
4453 const { render, unmount, createContainer} = getVersionedRenderImplementation ( ) ;
4554
4655 // @reactVersion >= 18.0
@@ -129,6 +138,72 @@ describe('Store', () => {
129138 ` ) ;
130139 } ) ;
131140
141+ it ( 'should handle reorder of filtered elements' , async ( ) => {
142+ function IgnoreMePassthrough ( { children} ) {
143+ return children ;
144+ }
145+ function PassThrough ( { children} ) {
146+ return children ;
147+ }
148+
149+ await actAsync (
150+ async ( ) =>
151+ ( store . componentFilters = [ createDisplayNameFilter ( '^IgnoreMe' , true ) ] ) ,
152+ ) ;
153+
154+ await act ( ( ) => {
155+ render (
156+ < PassThrough key = "e" name = "e" >
157+ < IgnoreMePassthrough key = "e1" >
158+ < PassThrough name = "e-child-one" >
159+ < p > e1</ p >
160+ </ PassThrough >
161+ </ IgnoreMePassthrough >
162+ < IgnoreMePassthrough key = "e2" >
163+ < PassThrough name = "e-child-two" >
164+ < div > e2</ div >
165+ </ PassThrough >
166+ </ IgnoreMePassthrough >
167+ </ PassThrough > ,
168+ ) ;
169+ } ) ;
170+
171+ expect ( store ) . toMatchInlineSnapshot ( `
172+ [root]
173+ ▾ <PassThrough key="e">
174+ ▾ <PassThrough>
175+ <p>
176+ ▾ <PassThrough>
177+ <div>
178+ ` ) ;
179+
180+ await act ( ( ) => {
181+ render (
182+ < PassThrough key = "e" name = "e" >
183+ < IgnoreMePassthrough key = "e2" >
184+ < PassThrough name = "e-child-two" >
185+ < div > e2</ div >
186+ </ PassThrough >
187+ </ IgnoreMePassthrough >
188+ < IgnoreMePassthrough key = "e1" >
189+ < PassThrough name = "e-child-one" >
190+ < p > e1</ p >
191+ </ PassThrough >
192+ </ IgnoreMePassthrough >
193+ </ PassThrough > ,
194+ ) ;
195+ } ) ;
196+
197+ expect ( store ) . toMatchInlineSnapshot ( `
198+ [root]
199+ ▾ <PassThrough key="e">
200+ ▾ <PassThrough>
201+ <div>
202+ ▾ <PassThrough>
203+ <p>
204+ ` ) ;
205+ } ) ;
206+
132207 describe ( 'StrictMode compliance' , ( ) => {
133208 it ( 'should mark strict root elements as strict' , async ( ) => {
134209 const App = ( ) => < Component /> ;
0 commit comments