Skip to content

Commit 3027716

Browse files
committed
Add spec examples for scope_id_to_model: false
This requires an upstream fix. However, given the potential to cause accessibility problems and broken UX (e.g. focus), we should track the current and desired/fixed behavior downstream. See primer/view_components#3696 See primer/view_components#3695
1 parent b966007 commit 3027716

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

spec/lib/primer/open_project/forms/rich_text_area_spec.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,25 @@ def render_form
7373
it_behaves_like "successful render", text_area_id: "comment_ultimate_answer"
7474
end
7575

76+
context "without prefixing model name" do
77+
let(:params) { { scope_id_to_model: false, rich_text_options: {} } }
78+
79+
it "renders the label" do
80+
pending "Primer Forms render incorrect label `for` value: primer/view_components#3695"
81+
82+
expect(rendered_form).to have_element :label, for: "ultimate_answer"
83+
end
84+
85+
it "renders the hidden textarea" do
86+
expect(rendered_form).to have_field "ultimate_answer", type: "textarea", visible: :hidden
87+
end
88+
89+
it "renders the rich text area" do
90+
expect(rendered_form).to have_element "opce-ckeditor-augmented-textarea",
91+
"data-text-area-id": "ultimate_answer".to_json
92+
end
93+
end
94+
7695
context "with explicit field id" do
7796
let(:params) { { id: "explicit_id", rich_text_options: {} } }
7897

@@ -87,6 +106,25 @@ def render_form
87106
it_behaves_like "successful render", text_area_id: "super_form_comment_ultimate_answer"
88107
end
89108

109+
context "without prefixing model name" do
110+
let(:params) { { scope_id_to_model: false, rich_text_options: {} } }
111+
112+
it "renders the label" do
113+
pending "Primer Forms render incorrect label `for` value: primer/view_components#3695"
114+
115+
expect(rendered_form).to have_element :label, for: "ultimate_answer"
116+
end
117+
118+
it "renders the hidden textarea" do
119+
expect(rendered_form).to have_field "super_form_ultimate_answer", type: "textarea", visible: :hidden
120+
end
121+
122+
it "renders the rich text area" do
123+
expect(rendered_form).to have_element "opce-ckeditor-augmented-textarea",
124+
"data-text-area-id": "super_form_ultimate_answer".to_json
125+
end
126+
end
127+
90128
context "with explicit field id" do
91129
let(:params) { { id: "explicit_id", rich_text_options: {} } }
92130

0 commit comments

Comments
 (0)