@@ -17,8 +17,10 @@ describe('Store', () => {
17
17
let act ;
18
18
let actAsync ;
19
19
let bridge ;
20
+ let createDisplayNameFilter ;
20
21
let getRendererID ;
21
22
let legacyRender ;
23
+ let previousComponentFilters ;
22
24
let store ;
23
25
let withErrorsOrWarningsIgnored ;
24
26
@@ -29,6 +31,8 @@ describe('Store', () => {
29
31
bridge = global . bridge ;
30
32
store = global . store ;
31
33
34
+ previousComponentFilters = store . componentFilters ;
35
+
32
36
React = require ( 'react' ) ;
33
37
ReactDOM = require ( 'react-dom' ) ;
34
38
ReactDOMClient = require ( 'react-dom/client' ) ;
@@ -38,9 +42,14 @@ describe('Store', () => {
38
42
actAsync = utils . actAsync ;
39
43
getRendererID = utils . getRendererID ;
40
44
legacyRender = utils . legacyRender ;
45
+ createDisplayNameFilter = utils . createDisplayNameFilter ;
41
46
withErrorsOrWarningsIgnored = utils . withErrorsOrWarningsIgnored ;
42
47
} ) ;
43
48
49
+ afterEach ( ( ) => {
50
+ store . componentFilters = previousComponentFilters ;
51
+ } ) ;
52
+
44
53
const { render, unmount, createContainer} = getVersionedRenderImplementation ( ) ;
45
54
46
55
// @reactVersion >= 18.0
@@ -129,6 +138,72 @@ describe('Store', () => {
129
138
` ) ;
130
139
} ) ;
131
140
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
+
132
207
describe ( 'StrictMode compliance' , ( ) => {
133
208
it ( 'should mark strict root elements as strict' , async ( ) => {
134
209
const App = ( ) => < Component /> ;
0 commit comments