@@ -157,44 +157,61 @@ describe('benchmark card bars', () => {
157157
158158 it ( 'extends a bundle-size bar to its whole-API ceiling only where tree-shaking leaves a gap' , async ( ) => {
159159 const bundleSize = FRAMEWORK_CARDS . find ( ( c ) => c . id === 'bundle-size' ) ! ;
160- const row = bundleSize . rows [ 0 ] ;
161- const ceilings = bundleSize . ceilings ! [ row . op as string ] ;
162160 const { container, opButton } = await mountCard ( bundleSize ) ;
163161
164- fireEvent . click ( opButton ( row . op as string ) ) ;
165-
166- await waitFor ( ( ) =>
167- expect ( opButton ( row . op as string ) . getAttribute ( 'aria-pressed' ) ) . toBe ( 'true' ) ,
168- ) ;
169- const ranged : string [ ] = [ ] ;
170- const single : string [ ] = [ ] ;
171- for ( const series of numericSeries ( bundleSize , 0 ) ) {
172- const value = row [ series . key ] as number ;
173- const ceiling = ceilings [ series . key ] ;
174- // Ranges whose ends round to the same kB stay single bars.
175- ( Math . round ( ceiling / 1024 ) > Math . round ( value / 1024 ) ? ranged : single ) . push ( series . key ) ;
176- }
177162 // The fixtures leave both kinds of framework on the card.
178- expect ( ranged . length ) . toBeGreaterThan ( 0 ) ;
179- expect ( single . length ) . toBeGreaterThan ( 0 ) ;
180-
181- const rows = Array . from ( container . querySelectorAll ( '.bench-row:not(.bench-row-empty)' ) ) ;
182- const labelOf = ( key : string ) => rows . find ( ( r ) => r . getAttribute ( 'data-series' ) === key ) ! ;
183- for ( const key of ranged ) {
184- const bar = labelOf ( key ) ;
185- expect ( bar . querySelector ( '.bench-fill-range' ) , key ) . not . toBeNull ( ) ;
186- expect ( bar . querySelector ( '.bench-val' ) ! . textContent , key ) . toMatch ( / k B – \d + k B $ / ) ;
187- }
188- for ( const key of single ) {
189- const bar = labelOf ( key ) ;
190- expect ( bar . querySelector ( '.bench-fill-range' ) , key ) . toBeNull ( ) ;
191- expect ( bar . querySelector ( '.bench-val' ) ! . textContent , key ) . not . toContain ( '–' ) ;
163+ let sawRange = false ;
164+ let sawSingle = false ;
165+ for ( const [ index , row ] of bundleSize . rows . entries ( ) ) {
166+ const ceilings = bundleSize . ceilings ! [ row . op as string ] ;
167+ fireEvent . click ( opButton ( row . op as string ) ) ;
168+ await waitFor ( ( ) =>
169+ expect ( opButton ( row . op as string ) . getAttribute ( 'aria-pressed' ) ) . toBe ( 'true' ) ,
170+ ) ;
171+ const ranged : string [ ] = [ ] ;
172+ const single : string [ ] = [ ] ;
173+ for ( const series of numericSeries ( bundleSize , index ) ) {
174+ const value = row [ series . key ] as number ;
175+ const ceiling = ceilings [ series . key ] ;
176+ // A separately built whole runtime can sit a few hundred gzip bytes
177+ // either side of the fixture and still round to another kilobyte.
178+ // Only a gap of at least 1 kB is unused client API.
179+ ( ceiling - value >= 1024 && Math . round ( ceiling / 1024 ) > Math . round ( value / 1024 )
180+ ? ranged
181+ : single
182+ ) . push ( series . key ) ;
183+ }
184+ if ( ranged . length > 0 ) sawRange = true ;
185+ if ( single . length > 0 ) sawSingle = true ;
186+
187+ const rows = Array . from ( container . querySelectorAll ( '.bench-row:not(.bench-row-empty)' ) ) ;
188+ const labelOf = ( key : string ) => rows . find ( ( r ) => r . getAttribute ( 'data-series' ) === key ) ! ;
189+ for ( const key of ranged ) {
190+ const bar = labelOf ( key ) ;
191+ const hatch = bar . querySelector < HTMLElement > ( '.bench-fill-range' ) ;
192+ const fill = bar . querySelector < HTMLElement > ( '.bench-fill' ) ! ;
193+ expect ( hatch , `${ row . op } /${ key } ` ) . not . toBeNull ( ) ;
194+ expect ( parseFloat ( hatch ! . style . width ) , `${ row . op } /${ key } ` ) . toBeGreaterThan ( 0 ) ;
195+ expect ( parseFloat ( fill . style . width ) , `${ row . op } /${ key } ` ) . toBeLessThanOrEqual ( 100 ) ;
196+ expect ( bar . querySelector ( '.bench-val' ) ! . textContent , `${ row . op } /${ key } ` ) . toMatch (
197+ / k B – \d + k B $ / ,
198+ ) ;
199+ }
200+ for ( const key of single ) {
201+ const bar = labelOf ( key ) ;
202+ const fill = bar . querySelector < HTMLElement > ( '.bench-fill' ) ! ;
203+ expect ( bar . querySelector ( '.bench-fill-range' ) , `${ row . op } /${ key } ` ) . toBeNull ( ) ;
204+ expect ( bar . querySelector ( '.bench-val' ) ! . textContent , `${ row . op } /${ key } ` ) . not . toContain ( '–' ) ;
205+ expect ( parseFloat ( fill . style . width ) , `${ row . op } /${ key } ` ) . toBeLessThanOrEqual ( 100 ) ;
206+ }
192207 }
208+ expect ( sawRange ) . toBe ( true ) ;
209+ expect ( sawSingle ) . toBe ( true ) ;
193210 // The exact ceilings stay readable without the hatching.
194211 const tableRows = Array . from ( container . querySelectorAll ( 'tbody th' ) , ( th ) =>
195212 th . textContent ! . trim ( ) ,
196213 ) ;
197- expect ( tableRows ) . toContain ( row . op + ', whole client API' ) ;
214+ expect ( tableRows ) . toContain ( bundleSize . rows [ 0 ] . op + ', whole client API' ) ;
198215 } ) ;
199216
200217 it ( 'charts a single-series card as one bar per operation, with no picker' , async ( ) => {
0 commit comments