Skip to content

Commit

Permalink
Fix page list component previews
Browse files Browse the repository at this point in the history
  • Loading branch information
lfdebrux committed Feb 7, 2025
1 parent 81a3dd5 commit 6a9122b
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions spec/components/page_list_component/page_list_component_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6a9122b

Please sign in to comment.