|
5 | 5 | let(:pages) { form.reload.pages } |
6 | 6 | let(:error_summary_component) { described_class.new(form) } |
7 | 7 |
|
8 | | - describe "rendering component" do |
| 8 | + describe "rendering component", feature_multiple_branches: false do |
9 | 9 | context "when there are no pages" do |
10 | 10 | it "is blank" do |
11 | 11 | render_inline(error_summary_component) |
|
138 | 138 | end |
139 | 139 |
|
140 | 140 | describe "#errors_for_summary" do |
141 | | - it "returns all of the routing errors for a form with their respective positions and links" do |
142 | | - expect(error_summary_component.errors_for_summary).to eq [ |
143 | | - OpenStruct.new(message: I18n.t("errors.page_conditions.answer_value_doesnt_exist", question_number: pages.first.position, route_number: 1), link: "#condition_#{condition_with_answer_value_missing.id}"), |
144 | | - OpenStruct.new(message: I18n.t("errors.page_conditions.goto_page_doesnt_exist", question_number: pages.second.position, route_number: 1), link: "#condition_#{condition_with_goto_page_missing.id}"), |
145 | | - ] |
| 141 | + context "when the multiple_branches feature is disabled", feature_multiple_branches: false do |
| 142 | + it "returns all of the routing errors for a form with their respective positions and links" do |
| 143 | + expect(error_summary_component.errors_for_summary).to eq [ |
| 144 | + OpenStruct.new(message: I18n.t("errors.page_conditions.answer_value_doesnt_exist", question_number: pages.first.position, route_number: 1), link: "#condition_#{condition_with_answer_value_missing.id}"), |
| 145 | + OpenStruct.new(message: I18n.t("errors.page_conditions.goto_page_doesnt_exist", question_number: pages.second.position, route_number: 1), link: "#condition_#{condition_with_goto_page_missing.id}"), |
| 146 | + ] |
| 147 | + end |
| 148 | + end |
| 149 | + |
| 150 | + context "when the multiple_branches feature is enabled", :feature_multiple_branches do |
| 151 | + it "returns an empty array" do |
| 152 | + expect(error_summary_component.errors_for_summary).to eq [] |
| 153 | + end |
| 154 | + |
| 155 | + context "when there is a backward route" do |
| 156 | + let(:expected_page_field_id) { "page-#{form.pages.second.id}" } |
| 157 | + |
| 158 | + before do |
| 159 | + create :condition, routing_page_id: form.pages.second.id, check_page_id: form.pages.second.id, goto_page_id: form.pages.first.id |
| 160 | + form.pages.second.reload |
| 161 | + end |
| 162 | + |
| 163 | + it "returns only the backward route error" do |
| 164 | + expect(error_summary_component.errors_for_summary).to eq [ |
| 165 | + OpenStruct.new(message: "A route from question 2 is going to a previous question - edit this route", link: "##{expected_page_field_id}"), |
| 166 | + ] |
| 167 | + end |
| 168 | + end |
146 | 169 | end |
147 | 170 | end |
148 | 171 | end |
|
0 commit comments