@@ -23,6 +23,16 @@ describe('Store component filters', () => {
2323 let utils ;
2424 let actAsync ;
2525
26+ beforeAll ( ( ) => {
27+ // JSDDOM doesn't implement getClientRects so we're just faking one for testing purposes
28+ Element . prototype . getClientRects = function ( this : Element ) {
29+ const textContent = this . textContent ;
30+ return [
31+ new DOMRect ( 1 , 2 , textContent . length , textContent . split ( '\n' ) . length ) ,
32+ ] ;
33+ } ;
34+ } ) ;
35+
2636 beforeEach ( ( ) => {
2737 bridge = global . bridge ;
2838 store = global . store ;
@@ -156,9 +166,9 @@ describe('Store component filters', () => {
156166 <div>
157167 ▾ <Suspense>
158168 <div>
159- [suspense-root] rects={[]}
160- <Suspense name="Unknown" rects={[]}>
161- <Suspense name="Unknown" rects={[]}>
169+ [suspense-root] rects={[{x:1,y:2,width:7,height:1}, {x:1,y:2,width:6,height:1} ]}
170+ <Suspense name="Unknown" rects={[{x:1,y:2,width:7,height:1} ]}>
171+ <Suspense name="Unknown" rects={[{x:1,y:2,width:6,height:1} ]}>
162172 ` ) ;
163173
164174 await actAsync (
@@ -174,9 +184,9 @@ describe('Store component filters', () => {
174184 <div>
175185 ▾ <Suspense>
176186 <div>
177- [suspense-root] rects={[]}
178- <Suspense name="Unknown" rects={[]}>
179- <Suspense name="Unknown" rects={[]}>
187+ [suspense-root] rects={[{x:1,y:2,width:7,height:1}, {x:1,y:2,width:6,height:1} ]}
188+ <Suspense name="Unknown" rects={[{x:1,y:2,width:7,height:1} ]}>
189+ <Suspense name="Unknown" rects={[{x:1,y:2,width:6,height:1} ]}>
180190 ` ) ;
181191
182192 await actAsync (
@@ -192,9 +202,9 @@ describe('Store component filters', () => {
192202 <div>
193203 ▾ <Suspense>
194204 <div>
195- [suspense-root] rects={[]}
196- <Suspense name="Unknown" rects={[]}>
197- <Suspense name="Unknown" rects={[]}>
205+ [suspense-root] rects={[{x:1,y:2,width:7,height:1}, {x:1,y:2,width:6,height:1} ]}
206+ <Suspense name="Unknown" rects={[{x:1,y:2,width:7,height:1} ]}>
207+ <Suspense name="Unknown" rects={[{x:1,y:2,width:6,height:1} ]}>
198208 ` ) ;
199209 } ) ;
200210
@@ -740,4 +750,82 @@ describe('Store component filters', () => {
740750 ` ) ;
741751 } ) ;
742752 } ) ;
753+
754+ // @reactVersion >= 19.2
755+ it ( 'can filter by Activity slices' , async ( ) => {
756+ const Activity = React . Activity ;
757+ const immediate = Promise . resolve ( < div > Immediate</ div > ) ;
758+
759+ function Root ( { children} ) {
760+ return (
761+ < Activity name = "/" mode = "visible" >
762+ < React . Suspense fallback = "Loading..." >
763+ < h1 > Root</ h1 >
764+ < main > { children } </ main >
765+ </ React . Suspense >
766+ </ Activity >
767+ ) ;
768+ }
769+
770+ function Layout ( { children} ) {
771+ return (
772+ < Activity name = "/blog" mode = "visible" >
773+ < h2 > Blog</ h2 >
774+ < section > { children } </ section >
775+ </ Activity >
776+ ) ;
777+ }
778+
779+ function Page ( ) {
780+ return < React . Suspense fallback = "Loading..." > { immediate } </ React . Suspense > ;
781+ }
782+
783+ await actAsync ( async ( ) =>
784+ render (
785+ < Root >
786+ < Layout >
787+ < Page />
788+ </ Layout >
789+ </ Root > ,
790+ ) ,
791+ ) ;
792+
793+ expect ( store ) . toMatchInlineSnapshot ( `
794+ [root]
795+ ▾ <Root>
796+ ▾ <Activity name="/">
797+ ▾ <Suspense>
798+ <h1>
799+ ▾ <main>
800+ ▾ <Layout>
801+ ▾ <Activity name="/blog">
802+ <h2>
803+ ▾ <section>
804+ ▾ <Page>
805+ ▾ <Suspense>
806+ <div>
807+ [suspense-root] rects={[{x:1,y:2,width:4,height:1}, {x:1,y:2,width:13,height:1}]}
808+ <Suspense name="Root" rects={[{x:1,y:2,width:4,height:1}, {x:1,y:2,width:13,height:1}]}>
809+ <Suspense name="Page" rects={[{x:1,y:2,width:9,height:1}]}>
810+ ` ) ;
811+
812+ await actAsync (
813+ async ( ) =>
814+ ( store . componentFilters = [
815+ utils . createActivitySliceFilter ( store . getElementIDAtIndex ( 1 ) ) ,
816+ ] ) ,
817+ ) ;
818+
819+ expect ( store ) . toMatchInlineSnapshot ( `
820+ [root]
821+ ▾ <Activity name="/">
822+ ▾ <Suspense>
823+ <h1>
824+ ▾ <main>
825+ ▾ <Layout>
826+ <Activity name="/blog">
827+ [suspense-root] rects={[{x:1,y:2,width:4,height:1}, {x:1,y:2,width:13,height:1}]}
828+ <Suspense name="Unknown" rects={[{x:1,y:2,width:4,height:1}, {x:1,y:2,width:13,height:1}]}>
829+ ` ) ;
830+ } ) ;
743831} ) ;
0 commit comments