@@ -310,4 +310,193 @@ describe('DiffWebviewProvider', function () {
310310 assert . ok ( html . includes ( 'Drift Status' ) )
311311 } )
312312 } )
313+
314+ describe ( 'deployment button conditional rendering' , function ( ) {
315+ it ( 'should show deploy button when changeset is CREATE_COMPLETE and deployments enabled' , function ( ) {
316+ const changes : StackChange [ ] = [
317+ {
318+ resourceChange : {
319+ action : 'Add' ,
320+ logicalResourceId : 'TestResource' ,
321+ } ,
322+ } ,
323+ ]
324+
325+ void provider . updateData (
326+ 'test-stack' ,
327+ changes ,
328+ 'test-changeset' ,
329+ true ,
330+ undefined ,
331+ undefined ,
332+ 'CREATE_COMPLETE'
333+ )
334+ const mockWebview = createMockWebview ( )
335+ provider . resolveWebviewView ( mockWebview as any )
336+
337+ assert . ok ( mockWebview . webview . html . includes ( 'Deploy Changes' ) )
338+ assert . ok ( mockWebview . webview . html . includes ( 'Delete Changeset' ) )
339+ } )
340+
341+ it ( 'should not show deploy button when changeset is not CREATE_COMPLETE' , function ( ) {
342+ const changes : StackChange [ ] = [
343+ {
344+ resourceChange : {
345+ action : 'Add' ,
346+ logicalResourceId : 'TestResource' ,
347+ } ,
348+ } ,
349+ ]
350+
351+ void provider . updateData (
352+ 'test-stack' ,
353+ changes ,
354+ 'test-changeset' ,
355+ true ,
356+ undefined ,
357+ undefined ,
358+ 'CREATE_IN_PROGRESS'
359+ )
360+ const mockWebview = createMockWebview ( )
361+ provider . resolveWebviewView ( mockWebview as any )
362+
363+ assert . ok ( ! mockWebview . webview . html . includes ( 'Deploy Changes' ) )
364+ assert . ok ( mockWebview . webview . html . includes ( 'Delete Changeset' ) )
365+ } )
366+
367+ it ( 'should not show deployment buttons when deployments not enabled' , function ( ) {
368+ const changes : StackChange [ ] = [
369+ {
370+ resourceChange : {
371+ action : 'Add' ,
372+ logicalResourceId : 'TestResource' ,
373+ } ,
374+ } ,
375+ ]
376+
377+ void provider . updateData (
378+ 'test-stack' ,
379+ changes ,
380+ 'test-changeset' ,
381+ false ,
382+ undefined ,
383+ undefined ,
384+ 'CREATE_COMPLETE'
385+ )
386+ const mockWebview = createMockWebview ( )
387+ provider . resolveWebviewView ( mockWebview as any )
388+
389+ assert . ok ( ! mockWebview . webview . html . includes ( 'Deploy Changes' ) )
390+ assert . ok ( ! mockWebview . webview . html . includes ( 'deployment-actions' ) )
391+ } )
392+
393+ it ( 'should not show deployment buttons when no changeset name' , function ( ) {
394+ const changes : StackChange [ ] = [
395+ {
396+ resourceChange : {
397+ action : 'Add' ,
398+ logicalResourceId : 'TestResource' ,
399+ } ,
400+ } ,
401+ ]
402+
403+ void provider . updateData ( 'test-stack' , changes , undefined , true , undefined , undefined , 'CREATE_COMPLETE' )
404+ const mockWebview = createMockWebview ( )
405+ provider . resolveWebviewView ( mockWebview as any )
406+
407+ assert . ok ( ! mockWebview . webview . html . includes ( 'Deploy Changes' ) )
408+ assert . ok ( ! mockWebview . webview . html . includes ( 'deployment-actions' ) )
409+ } )
410+ } )
411+
412+ describe ( 'pagination' , function ( ) {
413+ it ( 'should show pagination controls when changes exceed page size' , function ( ) {
414+ // Create 60 changes (exceeds default pageSize of 50)
415+ const changes : StackChange [ ] = Array . from ( { length : 60 } , ( _ , i ) => ( {
416+ resourceChange : {
417+ action : 'Add' ,
418+ logicalResourceId : `Resource${ i } ` ,
419+ resourceType : 'AWS::S3::Bucket' ,
420+ } ,
421+ } ) )
422+
423+ const html = setupProviderWithChanges ( 'test-stack' , changes )
424+
425+ assert . ok ( html . includes ( 'Page 1 of 2' ) )
426+ assert . ok ( html . includes ( 'nextPage()' ) )
427+ assert . ok ( html . includes ( 'prevPage()' ) )
428+ assert . ok ( html . includes ( 'pagination-controls' ) )
429+ } )
430+
431+ it ( 'should not show pagination for small change sets' , function ( ) {
432+ const changes : StackChange [ ] = [
433+ {
434+ resourceChange : {
435+ action : 'Add' ,
436+ logicalResourceId : 'SingleResource' ,
437+ resourceType : 'AWS::S3::Bucket' ,
438+ } ,
439+ } ,
440+ ]
441+
442+ const html = setupProviderWithChanges ( 'test-stack' , changes )
443+
444+ assert . ok ( ! html . includes ( 'pagination-controls' ) )
445+ assert . ok ( ! html . includes ( 'Page 1 of' ) )
446+ } )
447+
448+ it ( 'should display correct page numbers and navigation state' , function ( ) {
449+ const changes : StackChange [ ] = Array . from ( { length : 150 } , ( _ , i ) => ( {
450+ resourceChange : {
451+ action : 'Add' ,
452+ logicalResourceId : `Resource${ i } ` ,
453+ } ,
454+ } ) )
455+
456+ const html = setupProviderWithChanges ( 'test-stack' , changes )
457+
458+ assert . ok ( html . includes ( 'Page 1 of 3' ) )
459+ // Previous button should be disabled on first page
460+ assert . ok ( html . includes ( 'opacity: 0.5' ) )
461+ assert . ok ( html . includes ( 'cursor: not-allowed' ) )
462+ } )
463+ } )
464+
465+ describe ( 'empty changes handling' , function ( ) {
466+ it ( 'should show no changes message when changes is undefined' , function ( ) {
467+ void provider . updateData ( 'test-stack' , undefined as any , 'test-changeset' )
468+ const mockWebview = createMockWebview ( )
469+ provider . resolveWebviewView ( mockWebview as any )
470+
471+ assert . ok ( mockWebview . webview . html . includes ( 'No changes detected' ) )
472+ assert . ok ( mockWebview . webview . html . includes ( 'test-stack' ) )
473+ assert . ok ( mockWebview . webview . html . includes ( 'Delete Changeset' ) )
474+ } )
475+
476+ it ( 'should show no changes message when changes array is empty' , function ( ) {
477+ void provider . updateData ( 'empty-stack' , [ ] , 'test-changeset' )
478+ const mockWebview = createMockWebview ( )
479+ provider . resolveWebviewView ( mockWebview as any )
480+ const html = mockWebview . webview . html
481+
482+ assert . ok ( html . includes ( 'No changes detected' ) )
483+ assert . ok ( html . includes ( 'empty-stack' ) )
484+ assert . ok ( html . includes ( 'Delete Changeset' ) )
485+ } )
486+
487+ it ( 'should not show delete button when no changeset name' , function ( ) {
488+ const html = setupProviderWithChanges ( 'empty-stack' , [ ] )
489+
490+ assert . ok ( html . includes ( 'No changes detected' ) )
491+ assert . ok ( ! html . includes ( 'Delete Changeset' ) )
492+ } )
493+
494+ it ( 'should not show table when no changes' , function ( ) {
495+ const html = setupProviderWithChanges ( 'empty-stack' , [ ] )
496+
497+ assert . ok ( ! html . includes ( '<table' ) )
498+ assert . ok ( ! html . includes ( 'Action' ) )
499+ assert . ok ( ! html . includes ( 'LogicalResourceId' ) )
500+ } )
501+ } )
313502} )
0 commit comments