|
182 | 182 | end |
183 | 183 | end |
184 | 184 |
|
| 185 | + describe "rendering component with multiple branches feature", :feature_multiple_branches do |
| 186 | + context "when the form has multiple pages" do |
| 187 | + let(:form) { create :form, :ready_for_routing } |
| 188 | + let(:first_page) { form.pages.first } |
| 189 | + let(:third_page) { form.pages.third } |
| 190 | + let(:fourth_page) { form.pages.fourth } |
| 191 | + |
| 192 | + context "when the page has a single condition" do |
| 193 | + let!(:condition) { create :condition, routing_page_id: first_page.id, answer_value: "Option 1", goto_page_id: third_page.id } |
| 194 | + |
| 195 | + before do |
| 196 | + render_inline(page_list_component) |
| 197 | + end |
| 198 | + |
| 199 | + it "renders the condition description" do |
| 200 | + condition_description = "If the answer is:" |
| 201 | + condition_detail = "“#{condition.answer_value}” go to #{third_page.position}, “#{third_page.question_text}”" |
| 202 | + |
| 203 | + expect(page).to have_css("dd.govuk-summary-list__value", text: condition_description) |
| 204 | + expect(page).to have_css("dd.govuk-summary-list__value", text: condition_detail) |
| 205 | + end |
| 206 | + |
| 207 | + it "renders link" do |
| 208 | + expect(page).to have_link("Edit", href: routes_path(form_id: form.id, anchor: "page-#{first_page.position}")) |
| 209 | + end |
| 210 | + end |
| 211 | + |
| 212 | + context "when the page has branching conditions" do |
| 213 | + let!(:first_condition) { create :condition, routing_page_id: first_page.id, answer_value: "Option 1", goto_page_id: third_page.id } |
| 214 | + let!(:second_condition) { create :condition, routing_page_id: first_page.id, answer_value: "Option 2", goto_page_id: fourth_page.id } |
| 215 | + |
| 216 | + before do |
| 217 | + render_inline(page_list_component) |
| 218 | + end |
| 219 | + |
| 220 | + it "renders the condition description" do |
| 221 | + condition_description = "If the answer is:" |
| 222 | + first_condition_detail = "“#{first_condition.answer_value}” go to #{third_page.position}, “#{third_page.question_text}”" |
| 223 | + second_condition_detail = "“#{second_condition.answer_value}” go to #{fourth_page.position}, “#{fourth_page.question_text}”" |
| 224 | + |
| 225 | + expect(page).to have_css("dd.govuk-summary-list__value", text: condition_description) |
| 226 | + expect(page).to have_css("dd.govuk-summary-list__value", text: first_condition_detail) |
| 227 | + expect(page).to have_css("dd.govuk-summary-list__value", text: second_condition_detail) |
| 228 | + end |
| 229 | + end |
| 230 | + |
| 231 | + context "when the page has an unconditional route" do |
| 232 | + before do |
| 233 | + create :condition, routing_page_id: first_page.id, goto_page_id: third_page.id |
| 234 | + |
| 235 | + render_inline(page_list_component) |
| 236 | + end |
| 237 | + |
| 238 | + it "renders the condition description" do |
| 239 | + unconditional_route_description = "Go to #{third_page.position}, “#{third_page.question_text}”" |
| 240 | + |
| 241 | + expect(page).to have_css("dd.govuk-summary-list__value", text: unconditional_route_description) |
| 242 | + end |
| 243 | + end |
| 244 | + end |
| 245 | + end |
| 246 | + |
185 | 247 | describe "class methods", feature_multiple_branches: false do |
186 | 248 | let(:form) { create :form, :with_pages } |
187 | 249 |
|
|
0 commit comments