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)}}
|
@enter={{action (fn this.updateSelected option)}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{{#if this.customPromptValue.length}}
|
<DButton
|
||||||
<DButton
|
@class="ai-custom-prompt__submit btn-primary"
|
||||||
@class="ai-custom-prompt__submit btn-primary"
|
@icon="discourse-sparkles"
|
||||||
@icon="discourse-sparkles"
|
@action={{this.updateSelected}}
|
||||||
@action={{this.updateSelected}}
|
@actionParam={{option}}
|
||||||
@actionParam={{option}}
|
@disabled={{not this.customPromptValue.length}}
|
||||||
/>
|
/>
|
||||||
{{/if}}
|
|
||||||
</div>
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
<li data-name={{option.translated_name}} data-value={{option.id}}>
|
<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
|
expect(ai_helper_context_menu).to have_custom_prompt
|
||||||
end
|
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)
|
trigger_context_menu(OpenAiCompletionsInferenceStubs.translated_response)
|
||||||
ai_helper_context_menu.click_ai_button
|
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(
|
ai_helper_context_menu.fill_custom_prompt(
|
||||||
OpenAiCompletionsInferenceStubs.custom_prompt_input,
|
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
|
end
|
||||||
|
|
||||||
it "replaces the composed message with AI generated content" do
|
it "replaces the composed message with AI generated content" do
|
||||||
|
|
|
@ -98,6 +98,14 @@ module PageObjects
|
||||||
def has_no_custom_prompt_button?
|
def has_no_custom_prompt_button?
|
||||||
page.has_no_css?(CUSTOM_PROMPT_BUTTON_SELECTOR)
|
page.has_no_css?(CUSTOM_PROMPT_BUTTON_SELECTOR)
|
||||||
end
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue