Skip to content

Commit 22e9158

Browse files
committed
Add conditional step for CopyOfAnswers page
1 parent c052c84 commit 22e9158

2 files changed

Lines changed: 25 additions & 7 deletions

File tree

spec/support/feature_helpers.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,13 @@ def form_is_filled_in_by_form_filler(live_form_link, yes_branch: false, confirma
359359
end
360360
# rubocop:enable Style/IdenticalConditionalBranches
361361

362+
if filler_answer_email_enabled?
363+
logger.info "And I am asked if I want a copy of my answers"
364+
expect(page.find("h1")).to have_content "Do you want to get an email with a copy of your answers?"
365+
choose "No", visible: false
366+
click_button "Continue"
367+
end
368+
362369
logger.info "Then I can check my answers before I submit them"
363370
expect(page).to have_content "Check your answers before submitting your form"
364371
expect(page).to have_content "What is your favourite colour?"
@@ -580,6 +587,10 @@ def skip_file_upload?
580587
ENV.fetch("SKIP_FILE_UPLOAD", false)
581588
end
582589

590+
def filler_answer_email_enabled?
591+
Settings.features.filler_answer_email_enabled
592+
end
593+
583594
def visit_product_page
584595
logger.info "Visiting product pages at #{forms_product_page_url}"
585596
visit forms_product_page_url

spec/support/notify_helpers.rb

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,23 @@ def find_notification_reference(id)
99
page.find("##{id}", visible: false).value
1010
end
1111

12-
def wait_for_notification(notification_reference)
13-
email = NotifyService.new.get_email(notification_reference)
12+
def wait_for_notification(notification_reference, max_attempts: 10, wait_seconds: 2)
13+
notify_service = NotifyService.new
1414

15-
if email.collection && email.collection.first && email.collection.first.status
16-
status = email.collection.first.status
17-
logger.debug "Received the following status from Notify: #{status}"
18-
return email.collection.first
15+
max_attempts.times do |attempt|
16+
email = notify_service.get_email(notification_reference)
17+
18+
if email.collection&.first&.status
19+
status = email.collection.first.status
20+
logger.debug "Received the following status from Notify: #{status}"
21+
return email.collection.first
22+
end
23+
24+
logger.debug "Attempt #{attempt + 1}/#{max_attempts}: Notification not yet available, waiting #{wait_seconds}s..."
25+
sleep wait_seconds
1926
end
2027

21-
raise NotifyException, "ABORT!!! #{notification_reference} could not be found in Notify!!!"
28+
raise NotifyException, "ABORT!!! #{notification_reference} could not be found in Notify after #{max_attempts} attempts!"
2229
end
2330

2431
def wait_for_confirmation_code(notification_reference)

0 commit comments

Comments
 (0)