99 getColumnWidths ,
1010 getRowHeights ,
1111 getScrollingContainer ,
12+ onceResized ,
1213 setColspan ,
1314 setGap ,
1415 setMaximumColumnCount ,
@@ -40,7 +41,7 @@ describe('dashboard layout', () => {
4041 // Make the dashboard wide enough to fit all items on a single row
4142 dashboard . style . width = `${ columnWidth * dashboard . childElementCount } px` ;
4243
43- await nextFrame ( ) ;
44+ await onceResized ( dashboard ) ;
4445 // @ts -expect-error Test without padding
4546 dashboard . $ . grid . style . padding = '0' ;
4647
@@ -60,7 +61,7 @@ describe('dashboard layout', () => {
6061 it ( 'should be responsive' , async ( ) => {
6162 // Narrow down the component to fit one column
6263 dashboard . style . width = `${ columnWidth } px` ;
63- await nextFrame ( ) ;
64+ await onceResized ( dashboard ) ;
6465
6566 /* prettier-ignore */
6667 expectLayout ( dashboard , [
@@ -73,7 +74,7 @@ describe('dashboard layout', () => {
7374 dashboard . style . width = `${ columnWidth } px` ;
7475 const rowHeight = Math . ceil ( getRowHeights ( dashboard ) [ 0 ] ) ;
7576 dashboard . style . height = `${ rowHeight } px` ;
76- await nextFrame ( ) ;
77+ await onceResized ( dashboard ) ;
7778
7879 const scrollingContainer = getScrollingContainer ( dashboard ) ;
7980 expect ( getComputedStyle ( scrollingContainer ) . overflowY ) . to . eql ( 'auto' ) ;
@@ -85,7 +86,7 @@ describe('dashboard layout', () => {
8586
8687 it ( 'should scroll horizontally when content overflows' , async ( ) => {
8788 dashboard . style . width = `${ columnWidth / 2 } px` ;
88- await nextFrame ( ) ;
89+ await onceResized ( dashboard ) ;
8990
9091 const scrollingContainer = getScrollingContainer ( dashboard ) ;
9192 expect ( getComputedStyle ( scrollingContainer ) . overflowX ) . to . eql ( 'auto' ) ;
@@ -105,15 +106,15 @@ describe('dashboard layout', () => {
105106 setMinimumColumnWidth ( dashboard , undefined ) ;
106107 // Narrow down the component to have the width of 0
107108 dashboard . style . width = '0' ;
108- await nextFrame ( ) ;
109+ await onceResized ( dashboard ) ;
109110 // Expect the column width to equal the default minimum column width
110111 expect ( getColumnWidths ( dashboard ) ) . to . eql ( [ remValue * 25 ] ) ;
111112 } ) ;
112113
113114 it ( 'should have one overflown column if narrowed below minimum column width' , async ( ) => {
114115 // Narrow down the component to have the width of half a column
115116 dashboard . style . width = `${ columnWidth / 2 } px` ;
116- await nextFrame ( ) ;
117+ await onceResized ( dashboard ) ;
117118 // Expect the column width to still be the same (overflown)
118119 expect ( getColumnWidths ( dashboard ) ) . to . eql ( [ columnWidth ] ) ;
119120 } ) ;
@@ -123,7 +124,7 @@ describe('dashboard layout', () => {
123124 setMinimumColumnWidth ( dashboard , columnWidth / 2 ) ;
124125 // Narrow down the component to have the width of half a column
125126 dashboard . style . width = `${ columnWidth / 2 } px` ;
126- await nextFrame ( ) ;
127+ await onceResized ( dashboard ) ;
127128 // Expect the column width to equal the min column width
128129 expect ( getColumnWidths ( dashboard ) ) . to . eql ( [ columnWidth / 2 ] ) ;
129130 } ) ;
@@ -132,7 +133,7 @@ describe('dashboard layout', () => {
132133 setMaximumColumnWidth ( dashboard , columnWidth * 2 ) ;
133134 // Set the min column width to be twice as wide
134135 setMinimumColumnWidth ( dashboard , columnWidth * 2 ) ;
135- await nextFrame ( ) ;
136+ await onceResized ( dashboard ) ;
136137 // Expect there to only be one column with twice the width
137138 expect ( getColumnWidths ( dashboard ) ) . to . eql ( [ columnWidth * 2 ] ) ;
138139 /* prettier-ignore */
@@ -150,22 +151,22 @@ describe('dashboard layout', () => {
150151 expect ( getColumnWidths ( dashboard ) ) . to . eql ( [ columnWidth , columnWidth ] ) ;
151152 // Widen the component to have the width of 2.5 columns
152153 dashboard . style . width = `${ columnWidth * 2.5 } px` ;
153- await nextFrame ( ) ;
154+ await onceResized ( dashboard ) ;
154155 expect ( getColumnWidths ( dashboard ) ) . to . eql ( [ columnWidth * 1.25 , columnWidth * 1.25 ] ) ;
155156 // Widen the component to have the width of 3 columns
156157 dashboard . style . width = `${ columnWidth * 3 } px` ;
157- await nextFrame ( ) ;
158+ await onceResized ( dashboard ) ;
158159 expect ( getColumnWidths ( dashboard ) ) . to . eql ( [ columnWidth , columnWidth , columnWidth ] ) ;
159160 // Shrink the component to have the width of 1.5 columns
160161 dashboard . style . width = `${ columnWidth * 1.5 } px` ;
161- await nextFrame ( ) ;
162+ await onceResized ( dashboard ) ;
162163 expect ( getColumnWidths ( dashboard ) ) . to . eql ( [ columnWidth * 1.5 ] ) ;
163164 } ) ;
164165
165166 it ( 'should have one wide column with large maximum column width' , async ( ) => {
166167 // Allow the column to be twice as wide
167168 setMaximumColumnWidth ( dashboard , columnWidth * 2 ) ;
168- await nextFrame ( ) ;
169+ await onceResized ( dashboard ) ;
169170 // Expect there to only be one column with twice the width
170171 expect ( getColumnWidths ( dashboard ) ) . to . eql ( [ columnWidth * 2 ] ) ;
171172 /* prettier-ignore */
@@ -202,7 +203,7 @@ describe('dashboard layout', () => {
202203 it ( 'should use minimum row height for all rows' , async ( ) => {
203204 dashboard . style . width = `${ columnWidth } px` ;
204205 setMinimumRowHeight ( dashboard , rowHeight ) ;
205- await nextFrame ( ) ;
206+ await onceResized ( dashboard ) ;
206207 expect ( getRowHeights ( dashboard ) ) . to . eql ( [ rowHeight , rowHeight ] ) ;
207208 } ) ;
208209 } ) ;
@@ -224,7 +225,7 @@ describe('dashboard layout', () => {
224225 await nextFrame ( ) ;
225226
226227 dashboard . style . width = `${ columnWidth } px` ;
227- await nextFrame ( ) ;
228+ await onceResized ( dashboard ) ;
228229
229230 /* prettier-ignore */
230231 expectLayout ( dashboard , [
@@ -238,7 +239,7 @@ describe('dashboard layout', () => {
238239 await nextFrame ( ) ;
239240
240241 dashboard . style . width = `${ columnWidth * 3 } px` ;
241- await nextFrame ( ) ;
242+ await onceResized ( dashboard ) ;
242243
243244 /* prettier-ignore */
244245 expectLayout ( dashboard , [
@@ -264,7 +265,7 @@ describe('dashboard layout', () => {
264265 // Expect widget 1 to still have the same width
265266 expect ( childElements [ 1 ] . offsetWidth ) . to . eql ( widget1Width ) ;
266267
267- await nextFrame ( ) ;
268+ await onceResized ( dashboard ) ;
268269
269270 /* prettier-ignore */
270271 expectLayout ( dashboard , [
@@ -296,7 +297,7 @@ describe('dashboard layout', () => {
296297 await nextFrame ( ) ;
297298
298299 dashboard . style . width = `${ columnWidth } px` ;
299- await nextFrame ( ) ;
300+ await onceResized ( dashboard ) ;
300301
301302 /* prettier-ignore */
302303 expectLayout ( dashboard , [
@@ -313,7 +314,7 @@ describe('dashboard layout', () => {
313314 setGap ( dashboard , undefined ) ;
314315 // Increase the width of the dashboard to fit two items and a gap
315316 dashboard . style . width = `${ columnWidth * 2 + remValue } px` ;
316- await nextFrame ( ) ;
317+ await onceResized ( dashboard ) ;
317318
318319 const { right : item0Right } = childElements [ 0 ] . getBoundingClientRect ( ) ;
319320 const { left : item1Left } = childElements [ 1 ] . getBoundingClientRect ( ) ;
@@ -326,7 +327,7 @@ describe('dashboard layout', () => {
326327 setGap ( dashboard , customGap ) ;
327328 // Increase the width of the dashboard to fit two items and a gap
328329 dashboard . style . width = `${ columnWidth * 2 + customGap } px` ;
329- await nextFrame ( ) ;
330+ await onceResized ( dashboard ) ;
330331
331332 const { right : item0Right } = childElements [ 0 ] . getBoundingClientRect ( ) ;
332333 const { left : item1Left } = childElements [ 1 ] . getBoundingClientRect ( ) ;
@@ -338,7 +339,7 @@ describe('dashboard layout', () => {
338339 const customGap = 10 ;
339340 setGap ( dashboard , customGap ) ;
340341 dashboard . style . width = `${ columnWidth } px` ;
341- await nextFrame ( ) ;
342+ await onceResized ( dashboard ) ;
342343
343344 const { bottom : item0Bottom } = childElements [ 0 ] . getBoundingClientRect ( ) ;
344345 const { top : item1Top } = childElements [ 1 ] . getBoundingClientRect ( ) ;
@@ -350,21 +351,21 @@ describe('dashboard layout', () => {
350351 describe ( 'maximum column count' , ( ) => {
351352 it ( 'should not limit column count by default' , async ( ) => {
352353 dashboard . style . width = `${ columnWidth * 100 } px` ;
353- await nextFrame ( ) ;
354+ await onceResized ( dashboard ) ;
354355 expect ( getColumnWidths ( dashboard ) . length ) . to . eql ( 100 ) ;
355356 } ) ;
356357
357358 it ( 'should limit column count to custom value' , async ( ) => {
358359 setMaximumColumnCount ( dashboard , 5 ) ;
359360 dashboard . style . width = `${ columnWidth * 100 } px` ;
360- await nextFrame ( ) ;
361+ await onceResized ( dashboard ) ;
361362 expect ( getColumnWidths ( dashboard ) . length ) . to . eql ( 5 ) ;
362363 } ) ;
363364
364365 it ( 'should limit column count to one' , async ( ) => {
365366 setMaximumColumnCount ( dashboard , 1 ) ;
366367 dashboard . style . width = `${ columnWidth * 10 } px` ;
367- await nextFrame ( ) ;
368+ await onceResized ( dashboard ) ;
368369 /* prettier-ignore */
369370 expectLayout ( dashboard , [
370371 [ 0 ] ,
@@ -375,7 +376,7 @@ describe('dashboard layout', () => {
375376 it ( 'should allow fewer columns' , async ( ) => {
376377 setMaximumColumnCount ( dashboard , 2 ) ;
377378 dashboard . style . width = `${ columnWidth } px` ;
378- await nextFrame ( ) ;
379+ await onceResized ( dashboard ) ;
379380 /* prettier-ignore */
380381 expectLayout ( dashboard , [
381382 [ 0 ] ,
@@ -397,7 +398,7 @@ describe('dashboard layout', () => {
397398 it ( 'should increase max column count dynamically' , async ( ) => {
398399 setMaximumColumnCount ( dashboard , 2 ) ;
399400 dashboard . style . width = `${ columnWidth * 100 } px` ;
400- await nextFrame ( ) ;
401+ await onceResized ( dashboard ) ;
401402 expect ( getColumnWidths ( dashboard ) . length ) . to . eql ( 2 ) ;
402403
403404 setMaximumColumnCount ( dashboard , 20 ) ;
@@ -431,7 +432,7 @@ describe('dashboard layout', () => {
431432
432433 it ( 'should be on its own row' , async ( ) => {
433434 dashboard . style . width = `${ columnWidth * 4 } px` ;
434- await nextFrame ( ) ;
435+ await onceResized ( dashboard ) ;
435436
436437 /* prettier-ignore */
437438 expectLayout ( dashboard , [
@@ -443,7 +444,7 @@ describe('dashboard layout', () => {
443444 it ( 'following items should end up in the next row' , async ( ) => {
444445 dashboard . style . width = `${ columnWidth * 4 } px` ;
445446 dashboard . appendChild ( fixtureSync ( '<div id="item-4">Item 4</div>' ) ) ;
446- await nextFrame ( ) ;
447+ await onceResized ( dashboard ) ;
447448
448449 /* prettier-ignore */
449450 expectLayout ( dashboard , [
@@ -455,7 +456,7 @@ describe('dashboard layout', () => {
455456
456457 it ( 'should be capped to currently available columns' , async ( ) => {
457458 dashboard . style . width = `${ columnWidth } px` ;
458- await nextFrame ( ) ;
459+ await onceResized ( dashboard ) ;
459460
460461 /* prettier-ignore */
461462 expectLayout ( dashboard , [
@@ -469,7 +470,7 @@ describe('dashboard layout', () => {
469470 it ( 'should span multiple columns inside a section' , async ( ) => {
470471 dashboard . style . width = `${ columnWidth * 3 } px` ;
471472 setColspan ( childElements [ 2 ] , 2 ) ;
472- await nextFrame ( ) ;
473+ await onceResized ( dashboard ) ;
473474
474475 /* prettier-ignore */
475476 expectLayout ( dashboard , [
@@ -495,7 +496,7 @@ describe('dashboard layout', () => {
495496 it ( 'should use minimum row height for all section rows' , async ( ) => {
496497 dashboard . style . width = `${ columnWidth } px` ;
497498 setMinimumRowHeight ( dashboard , 300 ) ;
498- await nextFrame ( ) ;
499+ await onceResized ( dashboard ) ;
499500
500501 expect ( childElements [ 2 ] . offsetHeight ) . to . eql ( 300 ) ;
501502 expect ( childElements [ 3 ] . offsetHeight ) . to . eql ( 300 ) ;
@@ -514,23 +515,25 @@ describe('dashboard layout', () => {
514515 } ) ;
515516
516517 describe ( 'gap' , ( ) => {
517- it ( 'should have a default gap' , ( ) => {
518+ it ( 'should have a default gap' , async ( ) => {
518519 // Clear the gap used in the tests
519520 setGap ( dashboard , undefined ) ;
520521 // Increase the width of the dashboard to fit two items and a gap
521522 dashboard . style . width = `${ columnWidth * 2 + remValue } px` ;
523+ await onceResized ( dashboard ) ;
522524
523525 const { right : item2Right } = childElements [ 2 ] . getBoundingClientRect ( ) ;
524526 const { left : item3Left } = childElements [ 3 ] . getBoundingClientRect ( ) ;
525527 // Expect the items to have a gap of 1rem
526528 expect ( item3Left - item2Right ) . to . eql ( remValue ) ;
527529 } ) ;
528530
529- it ( 'should have a custom gap between items horizontally' , ( ) => {
531+ it ( 'should have a custom gap between items horizontally' , async ( ) => {
530532 const customGap = 10 ;
531533 setGap ( dashboard , customGap ) ;
532534 // Increase the width of the dashboard to fit two items and a gap
533535 dashboard . style . width = `${ columnWidth * 2 + customGap } px` ;
536+ await onceResized ( dashboard ) ;
534537
535538 const { right : item2Right } = childElements [ 2 ] . getBoundingClientRect ( ) ;
536539 const { left : item3Left } = childElements [ 3 ] . getBoundingClientRect ( ) ;
@@ -542,7 +545,7 @@ describe('dashboard layout', () => {
542545 const customGap = 10 ;
543546 setGap ( dashboard , customGap ) ;
544547 dashboard . style . width = `${ columnWidth } px` ;
545- await nextFrame ( ) ;
548+ await onceResized ( dashboard ) ;
546549
547550 const { bottom : item2Bottom } = childElements [ 2 ] . getBoundingClientRect ( ) ;
548551 const { top : item3Top } = childElements [ 3 ] . getBoundingClientRect ( ) ;
0 commit comments