@@ -403,3 +403,37 @@ def test_commit_message_length_cli_zero_disables_limit(
403403 )
404404 commands .Commit (config , {"message_length_limit" : 0 })()
405405 success_mock .assert_called_once ()
406+
407+
408+ @pytest .mark .usefixtures ("staging_is_clean" )
409+ def test_commit_preview_enhances_questions_passed_to_questionary_prompt (
410+ config , mocker : MockFixture
411+ ):
412+ prompt_return = {
413+ "prefix" : "feat" ,
414+ "subject" : "user created" ,
415+ "scope" : "" ,
416+ "is_breaking_change" : False ,
417+ "body" : "closes #21" ,
418+ "footer" : "" ,
419+ }
420+
421+ def prompt_side_effect (questions_to_ask , style = None ):
422+ input_questions = [q for q in questions_to_ask if q .get ("type" ) == "input" ]
423+ assert input_questions , "Expected at least one input question"
424+ q = input_questions [0 ]
425+ assert callable (q .get ("bottom_toolbar" ))
426+ assert callable (q .get ("validate" ))
427+ assert callable (q .get ("filter" ))
428+ return prompt_return
429+
430+ prompt_mock = mocker .patch ("questionary.prompt" , side_effect = prompt_side_effect )
431+ mocker .patch (
432+ "commitizen.git.commit" , return_value = cmd .Command ("success" , "" , b"" , b"" , 0 )
433+ )
434+
435+ commit_cmd = commands .Commit (config , {"preview" : True , "message_length_limit" : 0 })
436+ message = commit_cmd ._get_message_by_prompt_commit_questions ()
437+
438+ prompt_mock .assert_called_once ()
439+ assert "feat:" in message
0 commit comments