@@ -105,3 +105,109 @@ describe('pipes filter box', () => {
105105 expect ( document . activeElement ) . toBe ( host . querySelector ( 'input[type="search"]' ) ) ;
106106 } ) ;
107107} ) ;
108+
109+ describe ( 'pipes live data per page' , ( ) => {
110+ afterEach ( ( ) => {
111+ scopeToPage ( null ) ;
112+ document . body . innerHTML = '' ;
113+ } ) ;
114+
115+ const live = ( count : number ) => ( {
116+ name : 'price' ,
117+ className : 'PricePipe' ,
118+ isPure : true ,
119+ instanceCount : count ,
120+ components : [ { name : 'Cart' , count } ] ,
121+ } ) ;
122+
123+ function withPages ( snapshot : unknown ) {
124+ const rpc = {
125+ call : ( name : string ) =>
126+ Promise . resolve (
127+ name === 'get-pipes'
128+ ? [
129+ {
130+ name : 'price' ,
131+ className : 'PricePipe' ,
132+ file : 'src/price.pipe.ts' ,
133+ line : 4 ,
134+ isStandalone : true ,
135+ isPure : true ,
136+ builtin : false ,
137+ usageCount : 2 ,
138+ usages : [
139+ { file : 'src/cart.html' , line : 3 } ,
140+ { file : 'src/total.html' , line : 7 } ,
141+ ] ,
142+ } ,
143+ ]
144+ : [ ] ,
145+ ) ,
146+ callEvent : ( ) => Promise . resolve ( ) ,
147+ sharedState : ( ) => Promise . resolve ( { value : ( ) => snapshot , on : ( ) => ( ) => { } } ) ,
148+ } ;
149+ return { connectionMeta : { } , scope : ( ) => ( { rpc } ) } as unknown as DevframeRpcClient ;
150+ }
151+
152+ it ( 'shows only the page the panel belongs to when several pages report' , async ( ) => {
153+ scopeToPage ( 'B' ) ;
154+ const fixture = await render (
155+ withPages ( {
156+ pipes : [ live ( 5 ) ] ,
157+ async : [ ] ,
158+ reportedAt : 0 ,
159+ instrumented : [ ] ,
160+ pages : [
161+ { pageId : 'A' , pipes : [ live ( 3 ) ] , async : [ ] } ,
162+ { pageId : 'B' , pipes : [ live ( 2 ) ] , async : [ ] } ,
163+ ] ,
164+ } ) ,
165+ ) ;
166+ expect ( fixture . componentInstance . liveFor ( 'price' ) ?. instanceCount ) . toBe ( 2 ) ;
167+ } ) ;
168+
169+ it ( 'lists the template usages of a custom pipe' , async ( ) => {
170+ const fixture = await render (
171+ withPages ( { pipes : [ ] , async : [ ] , reportedAt : 0 , instrumented : [ ] } ) ,
172+ ) ;
173+ const component = fixture . componentInstance ;
174+ component . selected . set ( component . pipes ( ) [ 0 ] ) ;
175+ await fixture . whenStable ( ) ;
176+ const host = fixture . nativeElement as HTMLElement ;
177+ expect ( host . textContent ) . toContain ( 'Used in templates' ) ;
178+ expect ( host . textContent ) . toContain ( 'src/total.html:7' ) ;
179+ expect ( host . textContent ) . toContain ( '2 uses' ) ;
180+ } ) ;
181+
182+ it ( 'names the component and caller of each called instance' , async ( ) => {
183+ const fixture = await render (
184+ withPages ( {
185+ pipes : [
186+ {
187+ ...live ( 2 ) ,
188+ call : {
189+ callCount : 3 ,
190+ totalMs : 1.5 ,
191+ maxMs : 1 ,
192+ lastMs : 0.5 ,
193+ instances : [
194+ { component : 'Cart' , callCount : 2 , lastCaller : 'Cart.total (cart.ts:4)' } ,
195+ { component : 'Summary' , callCount : 1 , target : { pageId : 'A' , id : 's1' } } ,
196+ ] ,
197+ } ,
198+ } ,
199+ ] ,
200+ async : [ ] ,
201+ reportedAt : 0 ,
202+ instrumented : [ ] ,
203+ } ) ,
204+ ) ;
205+ const component = fixture . componentInstance ;
206+ component . selected . set ( component . pipes ( ) [ 0 ] ) ;
207+ await fixture . whenStable ( ) ;
208+ const host = fixture . nativeElement as HTMLElement ;
209+ expect ( host . textContent ) . toContain ( 'Cart.total (cart.ts:4)' ) ;
210+ expect ( host . textContent ) . toContain ( '1.50 ms total' ) ;
211+ expect ( host . querySelector ( 'button[aria-label="Highlight Summary on the page"]' ) ) . not . toBeNull ( ) ;
212+ } ) ;
213+ } ) ;
0 commit comments