@@ -195,6 +195,57 @@ func TestSelectForm(t *testing.T) {
195195 assert .Contains (t , view , "First letter" )
196196 })
197197
198+ t .Run ("descriptions use em-dash separator with lipgloss enabled" , func (t * testing.T ) {
199+ style .ToggleLipgloss (true )
200+ style .ToggleStyles (true )
201+ t .Cleanup (func () {
202+ style .ToggleLipgloss (false )
203+ style .ToggleStyles (false )
204+ })
205+
206+ fsMock := slackdeps .NewFsMock ()
207+ osMock := slackdeps .NewOsMock ()
208+ osMock .AddDefaultMocks ()
209+ cfg := config .NewConfig (fsMock , osMock )
210+ cfg .ExperimentsFlag = []string {"lipgloss" }
211+ cfg .LoadExperiments (context .Background (), func (_ context.Context , _ string , _ ... any ) {})
212+ io := NewIOStreams (cfg , fsMock , osMock )
213+
214+ var selected string
215+ options := []string {"Alpha" , "Beta" }
216+ selectCfg := SelectPromptConfig {
217+ Description : func (opt string , _ int ) string {
218+ if opt == "Alpha" {
219+ return "First letter"
220+ }
221+ return ""
222+ },
223+ }
224+ f := buildSelectForm (io , "Choose" , options , selectCfg , & selected )
225+ f .Update (f .Init ())
226+
227+ view := ansi .Strip (f .View ())
228+ assert .Contains (t , view , " — First letter" )
229+ })
230+
231+ t .Run ("descriptions use em-dash separator without lipgloss" , func (t * testing.T ) {
232+ var selected string
233+ options := []string {"Alpha" , "Beta" }
234+ selectCfg := SelectPromptConfig {
235+ Description : func (opt string , _ int ) string {
236+ if opt == "Alpha" {
237+ return "First letter"
238+ }
239+ return ""
240+ },
241+ }
242+ f := buildSelectForm (nil , "Choose" , options , selectCfg , & selected )
243+ f .Update (f .Init ())
244+
245+ view := ansi .Strip (f .View ())
246+ assert .Contains (t , view , "Alpha — First letter" )
247+ })
248+
198249 t .Run ("page size sets field height" , func (t * testing.T ) {
199250 var selected string
200251 options := []string {"A" , "B" , "C" , "D" , "E" , "F" , "G" , "H" }
@@ -283,8 +334,8 @@ func TestMultiSelectForm(t *testing.T) {
283334 m , _ := f .Update (key ('x' ))
284335 view := ansi .Strip (m .View ())
285336
286- // After toggle, the first item should show as selected (checkmark)
287- assert .Contains (t , view , "✓ " )
337+ // After toggle, the first item should show as selected
338+ assert .Contains (t , view , "[x] " )
288339 })
289340
290341 t .Run ("submit returns toggled items" , func (t * testing.T ) {
@@ -364,14 +415,51 @@ func TestFormsUseSlackTheme(t *testing.T) {
364415 })
365416}
366417
367- func TestFormsWithoutLipgloss (t * testing.T ) {
368- t .Run ("multi-select uses default prefix without lipgloss" , func (t * testing.T ) {
418+ func TestFormsUseSurveyTheme (t * testing.T ) {
419+ t .Run ("multi-select uses survey prefix without lipgloss" , func (t * testing.T ) {
369420 var selected []string
370421 f := buildMultiSelectForm (nil , "Pick" , []string {"A" , "B" }, & selected )
371422 f .Update (f .Init ())
372423
373424 view := ansi .Strip (f .View ())
374- // Without lipgloss the Slack theme is not applied, so "[ ]" should not appear
375- assert .NotContains (t , view , "[ ]" )
425+ // ThemeSurvey uses "[ ] " as unselected prefix
426+ assert .Contains (t , view , "[ ]" )
427+ })
428+
429+ t .Run ("multi-select uses [x] for selected prefix" , func (t * testing.T ) {
430+ var selected []string
431+ f := buildMultiSelectForm (nil , "Pick" , []string {"A" , "B" }, & selected )
432+ f .Update (f .Init ())
433+
434+ // Toggle first item
435+ m , _ := f .Update (key ('x' ))
436+ view := ansi .Strip (m .View ())
437+ assert .Contains (t , view , "[x]" )
438+ })
439+
440+ t .Run ("select form renders chevron cursor" , func (t * testing.T ) {
441+ var selected string
442+ f := buildSelectForm (nil , "Pick" , []string {"A" , "B" }, SelectPromptConfig {}, & selected )
443+ f .Update (f .Init ())
444+
445+ view := ansi .Strip (f .View ())
446+ assert .Contains (t , view , style .Chevron ()+ " A" )
447+ })
448+
449+ t .Run ("all form builders apply ThemeSurvey without lipgloss" , func (t * testing.T ) {
450+ var s string
451+ var b bool
452+ var ss []string
453+ forms := []* huh.Form {
454+ buildInputForm (nil , "msg" , InputPromptConfig {}, & s ),
455+ buildConfirmForm (nil , "msg" , & b ),
456+ buildSelectForm (nil , "msg" , []string {"a" }, SelectPromptConfig {}, & s ),
457+ buildPasswordForm (nil , "msg" , PasswordPromptConfig {}, & s ),
458+ buildMultiSelectForm (nil , "msg" , []string {"a" }, & ss ),
459+ }
460+ for _ , f := range forms {
461+ f .Update (f .Init ())
462+ assert .NotEmpty (t , f .View ())
463+ }
376464 })
377465}
0 commit comments