@@ -96,8 +96,10 @@ function makeChartPanelWrapper({
9696 ) ;
9797}
9898
99- function callUpdateFunction ( ) {
100- MockChart . mock . calls [ MockChart . mock . calls . length - 1 ] [ 0 ] ?. onUpdate ( ) ;
99+ function callUpdateFunction ( isLoading = false ) {
100+ MockChart . mock . calls [ MockChart . mock . calls . length - 1 ] [ 0 ] ?. onUpdate ( {
101+ isLoading,
102+ } ) ;
101103}
102104
103105function callErrorFunction ( ) {
@@ -390,6 +392,27 @@ it('shows loading spinner until an error is received B', async () => {
390392 checkPanelOverlays ( { container, isLoading : false } ) ;
391393} ) ;
392394
395+ it ( 'shows loading spinner until all series to process are loaded' , async ( ) => {
396+ const filterFields = [ ] ;
397+ const model = makeChartModel ( { filterFields } ) ;
398+ const modelPromise = Promise . resolve ( model ) ;
399+ const makeModel = ( ) => modelPromise ;
400+
401+ const { container } = render ( makeChartPanelWrapper ( { makeModel } ) ) ;
402+
403+ await act ( ( ) => expect ( modelPromise ) . resolves . toBe ( model ) ) ;
404+
405+ // Overlays shouldn't appear yet because we haven't received an update or error event, should just see loading
406+ expectLoading ( container ) ;
407+
408+ // Loading spinner should be shown until the update event is received and the isLoading flag is false
409+ callUpdateFunction ( true ) ;
410+ expectLoading ( container ) ;
411+
412+ callUpdateFunction ( false ) ;
413+ expectNotLoading ( container ) ;
414+ } ) ;
415+
393416describe ( 'linker column selection' , ( ) => {
394417 it ( 'does not show overlay if linker active but no filterable columns' , async ( ) => {
395418 const model = makeChartModel ( ) ;
0 commit comments