@@ -287,6 +287,161 @@ describe('PortalNavigationItemsComponent', () => {
287287 } ) ;
288288 } ) ;
289289
290+ describe ( 'resizing the sections panel' , ( ) => {
291+ beforeEach ( async ( ) => {
292+ await expectGetNavigationItems ( fakePortalNavigationItemsResponse ( { items : [ ] } ) ) ;
293+ } ) ;
294+
295+ it ( 'should have default panel width of 350px' , ( ) => {
296+ const component = fixture . componentInstance ;
297+ expect ( component . panelWidth ( ) ) . toBe ( 350 ) ;
298+ } ) ;
299+
300+ it ( 'should increase panel width when dragging right' , ( ) => {
301+ const component = fixture . componentInstance ;
302+ const resizeHandle = fixture . nativeElement . querySelector ( '.resize-handle' ) ;
303+
304+ const initialWidth = component . panelWidth ( ) ;
305+ expect ( initialWidth ) . toBe ( 350 ) ;
306+
307+ // Simulate mousedown
308+ const mousedownEvent = new MouseEvent ( 'mousedown' , {
309+ clientX : 100 ,
310+ bubbles : true ,
311+ cancelable : true ,
312+ } ) ;
313+ resizeHandle . dispatchEvent ( mousedownEvent ) ;
314+ fixture . detectChanges ( ) ;
315+
316+ // Simulate mousemove (dragging right by 50px)
317+ const mousemoveEvent = new MouseEvent ( 'mousemove' , {
318+ clientX : 150 ,
319+ bubbles : true ,
320+ cancelable : true ,
321+ } ) ;
322+ document . dispatchEvent ( mousemoveEvent ) ;
323+ fixture . detectChanges ( ) ;
324+
325+ expect ( component . panelWidth ( ) ) . toBe ( 400 ) ;
326+
327+ // Simulate mouseup
328+ const mouseupEvent = new MouseEvent ( 'mouseup' , {
329+ bubbles : true ,
330+ cancelable : true ,
331+ } ) ;
332+ document . dispatchEvent ( mouseupEvent ) ;
333+ fixture . detectChanges ( ) ;
334+ } ) ;
335+
336+ it ( 'should decrease panel width when dragging left' , ( ) => {
337+ const component = fixture . componentInstance ;
338+ const resizeHandle = fixture . nativeElement . querySelector ( '.resize-handle' ) ;
339+
340+ const initialWidth = component . panelWidth ( ) ;
341+ expect ( initialWidth ) . toBe ( 350 ) ;
342+
343+ // Simulate mousedown
344+ const mousedownEvent = new MouseEvent ( 'mousedown' , {
345+ clientX : 100 ,
346+ bubbles : true ,
347+ cancelable : true ,
348+ } ) ;
349+ resizeHandle . dispatchEvent ( mousedownEvent ) ;
350+ fixture . detectChanges ( ) ;
351+
352+ // Simulate mousemove (dragging left by 50px)
353+ const mousemoveEvent = new MouseEvent ( 'mousemove' , {
354+ clientX : 50 ,
355+ bubbles : true ,
356+ cancelable : true ,
357+ } ) ;
358+ document . dispatchEvent ( mousemoveEvent ) ;
359+ fixture . detectChanges ( ) ;
360+
361+ expect ( component . panelWidth ( ) ) . toBe ( 300 ) ;
362+
363+ // Simulate mouseup
364+ const mouseupEvent = new MouseEvent ( 'mouseup' , {
365+ bubbles : true ,
366+ cancelable : true ,
367+ } ) ;
368+ document . dispatchEvent ( mouseupEvent ) ;
369+ fixture . detectChanges ( ) ;
370+ } ) ;
371+
372+ it ( 'should constrain panel width to minimum of 280px' , ( ) => {
373+ const component = fixture . componentInstance ;
374+ const resizeHandle = fixture . nativeElement . querySelector ( '.resize-handle' ) ;
375+
376+ const initialWidth = component . panelWidth ( ) ;
377+ expect ( initialWidth ) . toBe ( 350 ) ;
378+
379+ // Simulate mousedown
380+ const mousedownEvent = new MouseEvent ( 'mousedown' , {
381+ clientX : 100 ,
382+ bubbles : true ,
383+ cancelable : true ,
384+ } ) ;
385+ resizeHandle . dispatchEvent ( mousedownEvent ) ;
386+ fixture . detectChanges ( ) ;
387+
388+ // Simulate mousemove (dragging left by 200px, which would go below minimum)
389+ const mousemoveEvent = new MouseEvent ( 'mousemove' , {
390+ clientX : - 100 ,
391+ bubbles : true ,
392+ cancelable : true ,
393+ } ) ;
394+ document . dispatchEvent ( mousemoveEvent ) ;
395+ fixture . detectChanges ( ) ;
396+
397+ expect ( component . panelWidth ( ) ) . toBe ( 280 ) ;
398+
399+ // Simulate mouseup
400+ const mouseupEvent = new MouseEvent ( 'mouseup' , {
401+ bubbles : true ,
402+ cancelable : true ,
403+ } ) ;
404+ document . dispatchEvent ( mouseupEvent ) ;
405+ fixture . detectChanges ( ) ;
406+ } ) ;
407+
408+ it ( 'should constrain panel width to maximum of 600px' , ( ) => {
409+ const component = fixture . componentInstance ;
410+ const resizeHandle = fixture . nativeElement . querySelector ( '.resize-handle' ) ;
411+
412+ const initialWidth = component . panelWidth ( ) ;
413+ expect ( initialWidth ) . toBe ( 350 ) ;
414+
415+ // Simulate mousedown
416+ const mousedownEvent = new MouseEvent ( 'mousedown' , {
417+ clientX : 100 ,
418+ bubbles : true ,
419+ cancelable : true ,
420+ } ) ;
421+ resizeHandle . dispatchEvent ( mousedownEvent ) ;
422+ fixture . detectChanges ( ) ;
423+
424+ // Simulate mousemove (dragging right by 300px, which would exceed maximum)
425+ const mousemoveEvent = new MouseEvent ( 'mousemove' , {
426+ clientX : 400 ,
427+ bubbles : true ,
428+ cancelable : true ,
429+ } ) ;
430+ document . dispatchEvent ( mousemoveEvent ) ;
431+ fixture . detectChanges ( ) ;
432+
433+ expect ( component . panelWidth ( ) ) . toBe ( 600 ) ;
434+
435+ // Simulate mouseup
436+ const mouseupEvent = new MouseEvent ( 'mouseup' , {
437+ bubbles : true ,
438+ cancelable : true ,
439+ } ) ;
440+ document . dispatchEvent ( mouseupEvent ) ;
441+ fixture . detectChanges ( ) ;
442+ } ) ;
443+ } ) ;
444+
290445 async function expectGetNavigationItems ( response : PortalNavigationItemsResponse = fakePortalNavigationItemsResponse ( ) ) {
291446 httpTestingController
292447 . expectOne ( { method : 'GET' , url : `${ CONSTANTS_TESTING . env . v2BaseURL } /portal-navigation-items?area=TOP_NAVBAR` } )
0 commit comments