This repository was archived by the owner on Jul 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +31
-4
lines changed
assets/javascripts/discourse Expand file tree Collapse file tree 5 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -25,9 +25,10 @@ export default class AiBotConversationsHiddenSubmit extends Service {
2525 this . composer . close ( ) ;
2626
2727 if ( this . inputValue . length < 10 ) {
28- // TODO: Translate
29- this . dialog . alert ( {
30- message : "Message must be longer than 10 characters" ,
28+ return this . dialog . alert ( {
29+ message : i18n (
30+ "discourse_ai.ai_bot.conversations.min_input_length_message"
31+ ) ,
3132 didConfirm : ( ) => this . focusInput ( ) ,
3233 didCancel : ( ) => this . focusInput ( ) ,
3334 } ) ;
Original file line number Diff line number Diff line change 1616 @action ={{ this.aiBotConversationsHiddenSubmit.submitToBot }}
1717 @icon =" paper-plane"
1818 @title =" discourse_ai.ai_bot.conversations.header"
19- class =" ai-bot-button btn-primary"
19+ class =" ai-bot-button btn-primary ai-conversation-submit "
2020 />
2121 </div >
2222 <p class =" ai-disclaimer" >
Original file line number Diff line number Diff line change 697697 disclaimer : " Generative AI can make mistakes"
698698 placeholder : " Ask a question..."
699699 new : " New Question"
700+ min_input_length_message : " Message must be longer than 10 characters"
700701 sentiments :
701702 dashboard :
702703 title : " Sentiment"
752753
753754 user_preferences :
754755 empty : " There are no relevant settings available at this time"
756+ experimental_homepage :
755757 review :
756758 types :
757759 reviewable_ai_post :
Original file line number Diff line number Diff line change 66 let ( :ai_pm_homepage ) { PageObjects ::Components ::AiPmHomepage . new }
77 let ( :sidebar ) { PageObjects ::Components ::NavigationMenu ::Sidebar . new }
88 let ( :header_dropdown ) { PageObjects ::Components ::NavigationMenu ::HeaderDropdown . new }
9+ let ( :dialog ) { PageObjects ::Components ::Dialog . new }
910
1011 fab! ( :user ) { Fabricate ( :user , refresh_auto_groups : true ) }
1112
104105 expect ( sidebar ) . to be_visible
105106 end
106107
108+ it "displays error when message is too short" do
109+ visit "/"
110+ find ( ".ai-bot-button" ) . click
111+
112+ ai_pm_homepage . input . fill_in ( with : "a" )
113+ ai_pm_homepage . submit
114+ expect ( ai_pm_homepage ) . to have_too_short_dialog
115+ dialog . click_yes
116+ expect ( composer ) . to be_closed
117+ end
118+
107119 it "renders sidebar even when navigation menu is set to header" do
108120 SiteSetting . navigation_menu = "header dropdown"
109121 visit "/"
Original file line number Diff line number Diff line change @@ -6,6 +6,18 @@ class AiPmHomepage < PageObjects::Components::Base
66 HOMEPAGE_BODY_CLASS = ".discourse-ai-bot-conversations-page"
77 HOMEPAGE_WRAPPER_CLASS = ".custom-homepage__content-wrapper"
88
9+ def input
10+ page . find ( "#custom-homepage-input" )
11+ end
12+
13+ def submit
14+ page . find ( ".ai-conversation-submit" ) . click
15+ end
16+
17+ def has_too_short_dialog?
18+ page . find ( ".dialog-content" , text : "Message must be longer than 10 characters" )
19+ end
20+
921 def has_homepage?
1022 page . has_css? ( "#{ HOMEPAGE_BODY_CLASS } #{ HOMEPAGE_WRAPPER_CLASS } " )
1123 end
You can’t perform that action at this time.
0 commit comments