From 6a9122bf6d75f8b62e5dc59ce57642d70b06b93a Mon Sep 17 00:00:00 2001 From: Laurence de Bruxelles Date: Thu, 6 Feb 2025 15:30:43 +0200 Subject: [PATCH] Fix page list component previews --- .../page_list_component_preview.rb | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/spec/components/page_list_component/page_list_component_preview.rb b/spec/components/page_list_component/page_list_component_preview.rb index f7738f8e3..d9b192bbe 100644 --- a/spec/components/page_list_component/page_list_component_preview.rb +++ b/spec/components/page_list_component/page_list_component_preview.rb @@ -6,39 +6,39 @@ def default end def with_pages_and_no_conditions - pages = [OpenStruct.new(id: 1, position: 1, question_text: "Enter your name", conditions: []), - OpenStruct.new(id: 2, position: 2, question_text: "What is your pet's phone number?", conditions: []), - OpenStruct.new(id: 3, position: 3, question_text: "How many pets do you own?", conditions: [])] + pages = [build(:page, id: 1, position: 1, question_text: "Enter your name", routing_conditions: []), + build(:page, id: 2, position: 2, question_text: "What is your pet's phone number?", routing_conditions: []), + build(:page, id: 3, position: 3, question_text: "How many pets do you own?", routing_conditions: [])] render(PageListComponent::View.new(pages:, form_id: 0)) end def with_pages_and_one_condition - conditions = [(build :condition, id: 1, routing_page_id: 1, check_page_id: 1, answer_value: "Wales", goto_page_id: 3)] - pages = [OpenStruct.new(id: 1, position: 1, question_text: "Enter your name", conditions:), - OpenStruct.new(id: 2, position: 2, question_text: "What is your pet's phone number?", conditions: []), - OpenStruct.new(id: 3, position: 3, question_text: "How many pets do you own?", conditions: [])] + routing_conditions = [(build :condition, id: 1, routing_page_id: 1, check_page_id: 1, answer_value: "Wales", goto_page_id: 3)] + pages = [build(:page, id: 1, position: 1, question_text: "Enter your name", routing_conditions:), + build(:page, id: 2, position: 2, question_text: "What is your pet's phone number?", routing_conditions: []), + build(:page, id: 3, position: 3, question_text: "How many pets do you own?", routing_conditions: [])] render(PageListComponent::View.new(pages:, form_id: 0)) end def with_pages_and_multiple_conditions routing_conditions_1 = [(build :condition, id: 1, routing_page_id: 1, check_page_id: 1, answer_value: "Wales", goto_page_id: 3), (build :condition, id: 2, routing_page_id: 1, check_page_id: 1, answer_value: "England", goto_page_id: 2)] - routing_conditions_2 = [(build :condition, id: 3, routing_page_id: 1, check_page_id: 1, answer_value: "Wales", goto_page_id: 3), - (build :condition, id: 4, routing_page_id: 1, check_page_id: 1, answer_value: "England", goto_page_id: 2)] - pages = [(build :page, id: 1, question_text: "Enter your name", routing_conditions: routing_conditions_1), - (build :page, id: 2, question_text: "What is your pet's phone number?", routing_conditions: routing_conditions_2), - (build :page, id: 3, question_text: "How many pets do you own?", routing_conditions: [])] + routing_conditions_2 = [(build :condition, id: 3, routing_page_id: 2, check_page_id: 2, answer_value: "Wales", goto_page_id: 3), + (build :condition, id: 4, routing_page_id: 2, check_page_id: 2, answer_value: "England", goto_page_id: 2)] + pages = [(build :page, id: 1, position: 1, question_text: "Enter your name", routing_conditions: routing_conditions_1), + (build :page, id: 2, position: 2, question_text: "What is your pet's phone number?", routing_conditions: routing_conditions_2), + (build :page, id: 3, position: 3, question_text: "How many pets do you own?", routing_conditions: [])] render(PageListComponent::View.new(pages:, form_id: 0)) end def with_pages_and_conditions_with_errors - routing_conditions = [(build :condition, :with_answer_value_missing, id: 1, routing_page_id: 1, check_page_id: 1, goto_page_id: 3), - (build :condition, :with_goto_page_missing, id: 2, routing_page_id: 1, check_page_id: 1, answer_value: "England"), - (build :condition, :with_answer_value_and_goto_page_missing, id: 3, routing_page_id: 1, check_page_id: 1), - (build :condition, :with_goto_page_before_check_page, id: 4, routing_page_id: 2, check_page_id: 2, answer_value: "England", goto_page_id: 1), - (build :condition, :with_goto_page_immediately_after_check_page, id: 5, routing_page_id: 1, check_page_id: 1, answer_value: "Wales", goto_page_id: 2)] - pages = [(build :page, id: 1, position: 1, question_text: "Enter your name", routing_conditions:), - (build :page, id: 2, position: 2, question_text: "What is your pet's phone number?", routing_conditions: []), + routing_conditions_1 = [(build :condition, :with_answer_value_missing, id: 1, routing_page_id: 1, check_page_id: 1, goto_page_id: 3), + (build :condition, :with_goto_page_missing, id: 2, routing_page_id: 1, check_page_id: 1, answer_value: "England"), + (build :condition, :with_answer_value_and_goto_page_missing, id: 3, routing_page_id: 1, check_page_id: 1), + (build :condition, :with_goto_page_immediately_after_check_page, id: 5, routing_page_id: 1, check_page_id: 1, answer_value: "Wales", goto_page_id: 2)] + routing_conditions_2 = [(build :condition, :with_goto_page_before_check_page, id: 4, routing_page_id: 2, check_page_id: 2, answer_value: "England", goto_page_id: 1)] + pages = [(build :page, id: 1, position: 1, question_text: "Enter your name", routing_conditions: routing_conditions_1), + (build :page, id: 2, position: 2, question_text: "What is your pet's phone number?", routing_conditions: routing_conditions_2), (build :page, id: 3, position: 3, question_text: "How many pets do you own?", routing_conditions: [])] render(PageListComponent::View.new(pages:, form_id: 0)) end