@@ -17,7 +17,7 @@ const prompt: PendingUserInput = {
1717 {
1818 label : "Incremental" ,
1919 description : "Move one module at a time" ,
20- preview : "**Safe rollout**\n\n```ts\nconst batchSize = 1;\n```" ,
20+ preview : "**Safe rollout**\n\n```ts\nconst batchSize = 1;\n```\n\n " ,
2121 } ,
2222 { label : "Big bang" , description : "Move everything in one release" } ,
2323 ] ,
@@ -27,12 +27,15 @@ const prompt: PendingUserInput = {
2727 dismissible : true ,
2828} ;
2929
30- function renderPanel ( pendingUserInput : PendingUserInput = prompt ) {
30+ function renderPanel (
31+ pendingUserInput : PendingUserInput = prompt ,
32+ answers : Record < string , { selectedOptionValues ?: string [ ] ; customAnswer ?: string } > = { } ,
33+ ) {
3134 return renderToStaticMarkup (
3235 < ComposerPendingUserInputPanel
3336 pendingUserInputs = { [ pendingUserInput ] }
3437 respondingRequestIds = { [ ] }
35- answers = { { } }
38+ answers = { answers }
3639 questionIndex = { 0 }
3740 onToggleOption = { ( ) => { } }
3841 onAdvance = { ( ) => { } }
@@ -78,5 +81,19 @@ describe("ComposerPendingUserInputPanel", () => {
7881 expect ( markup ) . toContain ( 'data-pending-user-input-preview="Incremental"' ) ;
7982 expect ( markup ) . toContain ( "<strong>Safe rollout</strong>" ) ;
8083 expect ( markup ) . toContain ( "const batchSize = 1;" ) ;
84+ expect ( markup ) . not . toContain ( "<img" ) ;
85+ expect ( markup ) . not . toContain ( "tracker.invalid" ) ;
86+ } ) ;
87+
88+ it ( "keeps the preview clear when the last selected multi-option has no preview" , ( ) => {
89+ const multiPrompt : PendingUserInput = {
90+ ...prompt ,
91+ questions : [ { ...prompt . questions [ 0 ] ! , multiSelect : true } ] ,
92+ } ;
93+ const markup = renderPanel ( multiPrompt , {
94+ "question-1" : { selectedOptionValues : [ "Incremental" , "Big bang" ] } ,
95+ } ) ;
96+
97+ expect ( markup ) . not . toContain ( "data-pending-user-input-preview" ) ;
8198 } ) ;
8299} ) ;
0 commit comments