Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Make AttributeHelpTextComponent render QA data

Alexander Brandon Coles86a81360493d
diff --git a/app/components/open_project/common/attribute_help_text_component.rb b/app/components/open_project/common/attribute_help_text_component.rb
index 85e191c7444..e77160b11c3 100644
--- a/app/components/open_project/common/attribute_help_text_component.rb
+++ b/app/components/open_project/common/attribute_help_text_component.rb
@@ -66,6 +66,7 @@ module OpenProject
return unless @help_text
@system_arguments[:href] = show_dialog_attribute_help_text_path(@help_text)
+ @system_arguments[:data][:qa_help_text_for] = @help_text.attribute_name.camelize(:lower)
end
end
end
diff --git a/spec/components/open_project/common/attribute_help_text_component_spec.rb b/spec/components/open_project/common/attribute_help_text_component_spec.rb
index cdf3bd5cf72..a33014b3d3f 100644
--- a/spec/components/open_project/common/attribute_help_text_component_spec.rb
+++ b/spec/components/open_project/common/attribute_help_text_component_spec.rb
@@ -67,6 +67,16 @@ RSpec.describe OpenProject::Common::AttributeHelpTextComponent, type: :component
it "applies an ID" do
expect(subject).to have_element :a, id: /attribute-help-text-component-\d+/
end
+
+ it "defines a data-qa-help-text-for attribute" do
+ expect(subject).to have_element :a, "data-qa-help-text-for": attribute_name.to_s.camelize(:lower)
+ end
+
+ context "without an additional label" do
+ it "does not render additional label content" do
+ expect(subject).to have_no_css ".Link-content"
+ end
+ end
end
shared_examples "component does not render" do
@@ -80,15 +90,35 @@ RSpec.describe OpenProject::Common::AttributeHelpTextComponent, type: :component
end
context "with a project help text" do
- let(:help_text) { build_stubbed(:project_help_text) }
+ let(:help_text) { build_stubbed(:project_help_text, attribute_name:) }
+
+ context "for a default attribute" do
+ let(:attribute_name) { :name }
+
+ it_behaves_like "component renders"
+ end
- it_behaves_like "component renders"
+ context "for a project attribute" do
+ let(:attribute_name) { :custom_field_2105 }
+
+ it_behaves_like "component renders"
+ end
end
context "with a work package help text" do
- let(:help_text) { build_stubbed(:work_package_help_text) }
+ let(:help_text) { build_stubbed(:work_package_help_text, attribute_name:) }
- it_behaves_like "component renders"
+ context "for a default attribute" do
+ let(:attribute_name) { :subject }
+
+ it_behaves_like "component renders"
+ end
+
+ context "for a custom field attribute" do
+ let(:attribute_name) { :custom_field_99 }
+
+ it_behaves_like "component renders"
+ end
end
context "with nil help text" do