File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -108,4 +108,35 @@ describe('NotebookPicker', () => {
108108 expect ( select . options . length ) . toBeGreaterThanOrEqual ( 1 ) ;
109109 expect ( select . options [ 0 ] && select . options [ 0 ] . value ) . toBe ( '-' ) ;
110110 } ) ;
111+
112+ it ( 'should handle context.ready rejection gracefully' , async ( ) => {
113+ const consoleErrorSpy = jest
114+ . spyOn ( console , 'error' )
115+ . mockImplementation ( ( ) => { } ) ;
116+ const errorPanel = {
117+ context : {
118+ ready : Promise . reject ( new Error ( 'Failed to initialize' ) ) ,
119+ model : {
120+ getMetadata : jest . fn ( )
121+ }
122+ } ,
123+ model
124+ } as any ;
125+
126+ document . body . innerHTML = '' ;
127+ const widget = new NotebookPicker ( errorPanel ) ;
128+ // Override onAfterAttach to avoid errors from this.parent being null
129+ ( widget as any ) . onAfterAttach = jest . fn ( ) ;
130+ Widget . attach ( widget , document . body ) ;
131+ await framePromise ( ) ;
132+
133+ await new Promise ( resolve => setTimeout ( resolve , 10 ) ) ;
134+
135+ expect ( consoleErrorSpy ) . toHaveBeenCalledWith (
136+ 'Failed to initialize NotebookPicker:' ,
137+ expect . any ( Error )
138+ ) ;
139+
140+ consoleErrorSpy . mockRestore ( ) ;
141+ } ) ;
111142} ) ;
You can’t perform that action at this time.
0 commit comments