@@ -909,13 +909,12 @@ is between the function definition and its body."
909909 (should-not (string-match-p " summary" captured-prompt))))))
910910
911911(ert-deftest ai-code-test-insert-prompt-org-heading-append-summary-yes ()
912- " Test that `ai-code--insert-prompt' appends summary instruction on org heading when user confirms."
912+ " Test that `ai-code--insert-prompt' appends summary instruction on prompt-mode heading when user confirms."
913913 (with-temp-buffer
914- (require 'org )
915- (setq buffer-file-name " /tmp/project/plan.org" )
914+ (setq buffer-file-name " /tmp/project/.ai.code.files/.ai.code.prompt.org" )
916915 (insert " * TODO Build search feature\n " )
917916 (insert " Design the API first.\n " )
918- (org -mode )
917+ (ai-code-prompt -mode)
919918 (goto-char (point-min ))
920919
921920 (let (captured-prompt
@@ -929,16 +928,15 @@ is between the function definition and its body."
929928 (should (stringp captured-prompt))
930929 (should (string-match-p " Test prompt text" captured-prompt))
931930 (should (string-match-p " summary" captured-prompt))
932- (should (string-match-p " plan \\ .org" captured-prompt))))))
931+ (should (string-match-p " \\ .ai \\ .code \\ .prompt \\ .org" captured-prompt))))))
933932
934933(ert-deftest ai-code-test-insert-prompt-org-heading-append-summary-no ()
935934 " Test that `ai-code--insert-prompt' does NOT append summary when user declines."
936935 (with-temp-buffer
937- (require 'org )
938- (setq buffer-file-name " /tmp/project/plan.org" )
936+ (setq buffer-file-name " /tmp/project/.ai.code.files/.ai.code.prompt.org" )
939937 (insert " * TODO Build search feature\n " )
940938 (insert " Design the API first.\n " )
941- (org -mode )
939+ (ai-code-prompt -mode)
942940 (goto-char (point-min ))
943941
944942 (let (captured-prompt
@@ -953,8 +951,8 @@ is between the function definition and its body."
953951 (should (string-match-p " Test prompt text" captured-prompt))
954952 (should-not (string-match-p " summary" captured-prompt))))))
955953
956- (ert-deftest ai-code-test-insert-prompt-non-org -no-summary-asked ()
957- " Test that `ai-code--insert-prompt' does NOT ask about summary in non-org buffer."
954+ (ert-deftest ai-code-test-insert-prompt-non-prompt-mode -no-summary-asked ()
955+ " Test that `ai-code--insert-prompt' does NOT ask about summary in non-prompt-mode buffer."
958956 (with-temp-buffer
959957 (setq buffer-file-name " /tmp/project/test.el" )
960958 (setq-local comment-start " ;" )
@@ -976,6 +974,30 @@ is between the function definition and its body."
976974 (should (string-match-p " Test prompt text" captured-prompt))
977975 (should-not (string-match-p " summary" captured-prompt))))))
978976
977+ (ert-deftest ai-code-test-insert-prompt-slash-command-on-heading-executes ()
978+ " Test that slash commands execute directly even when on a prompt-mode heading."
979+ (with-temp-buffer
980+ (setq buffer-file-name " /tmp/project/.ai.code.files/.ai.code.prompt.org" )
981+ (insert " * TODO Build search feature\n " )
982+ (ai-code-prompt-mode)
983+ (goto-char (point-min ))
984+
985+ (let (y-or-n-called command-executed
986+ (ai-code-prompt-preprocess-filepaths nil ))
987+ (cl-letf (((symbol-function 'y-or-n-p )
988+ (lambda (_ )
989+ (setq y-or-n-called t )
990+ t ))
991+ ((symbol-function 'ai-code--execute-command )
992+ (lambda (_cmd ) (setq command-executed t )))
993+ ((symbol-function 'ai-code--write-prompt-to-file-and-send )
994+ (lambda (_ ) (error " Should not reach write-prompt " ))))
995+
996+ (ai-code--insert-prompt " /status" )
997+
998+ (should command-executed)
999+ (should-not y-or-n-called)))))
1000+
9791001(provide 'test_ai-code-change )
9801002
9811003; ;; test_ai-code-change.el ends here
0 commit comments