UX: Use disable/enable state for custom prompt button (#233)
This commit is contained in:
parent
0c50d7d553
commit
237e9478df
|
@ -28,14 +28,13 @@
|
|||
@enter={{action (fn this.updateSelected option)}}
|
||||
/>
|
||||
|
||||
{{#if this.customPromptValue.length}}
|
||||
<DButton
|
||||
@class="ai-custom-prompt__submit btn-primary"
|
||||
@icon="discourse-sparkles"
|
||||
@action={{this.updateSelected}}
|
||||
@actionParam={{option}}
|
||||
/>
|
||||
{{/if}}
|
||||
<DButton
|
||||
@class="ai-custom-prompt__submit btn-primary"
|
||||
@icon="discourse-sparkles"
|
||||
@action={{this.updateSelected}}
|
||||
@actionParam={{option}}
|
||||
@disabled={{not this.customPromptValue.length}}
|
||||
/>
|
||||
</div>
|
||||
{{else}}
|
||||
<li data-name={{option.translated_name}} data-value={{option.id}}>
|
||||
|
|
|
@ -74,14 +74,14 @@ RSpec.describe "AI Composer helper", type: :system, js: true do
|
|||
expect(ai_helper_context_menu).to have_custom_prompt
|
||||
end
|
||||
|
||||
it "shows the custom prompt button when input is filled" do
|
||||
it "enables the custom prompt button when input is filled" do
|
||||
trigger_context_menu(OpenAiCompletionsInferenceStubs.translated_response)
|
||||
ai_helper_context_menu.click_ai_button
|
||||
expect(ai_helper_context_menu).to have_no_custom_prompt_button
|
||||
expect(ai_helper_context_menu).to have_custom_prompt_button_disabled
|
||||
ai_helper_context_menu.fill_custom_prompt(
|
||||
OpenAiCompletionsInferenceStubs.custom_prompt_input,
|
||||
)
|
||||
expect(ai_helper_context_menu).to have_custom_prompt_button
|
||||
expect(ai_helper_context_menu).to have_custom_prompt_button_enabled
|
||||
end
|
||||
|
||||
it "replaces the composed message with AI generated content" do
|
||||
|
|
|
@ -98,6 +98,14 @@ module PageObjects
|
|||
def has_no_custom_prompt_button?
|
||||
page.has_no_css?(CUSTOM_PROMPT_BUTTON_SELECTOR)
|
||||
end
|
||||
|
||||
def has_custom_prompt_button_enabled?
|
||||
page.has_css?("#{CUSTOM_PROMPT_BUTTON_SELECTOR}:not(:disabled)")
|
||||
end
|
||||
|
||||
def has_custom_prompt_button_disabled?
|
||||
page.has_css?("#{CUSTOM_PROMPT_BUTTON_SELECTOR}:disabled")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue