diff --git a/spec/support/travel_advice_publisher_helpers.rb b/spec/support/travel_advice_publisher_helpers.rb index 426b7b16..9b3d7758 100644 --- a/spec/support/travel_advice_publisher_helpers.rb +++ b/spec/support/travel_advice_publisher_helpers.rb @@ -66,6 +66,11 @@ def visit_travel_advice_publisher(path = "/") visit(Plek.find("travel-advice-publisher") + path) end + def reload_until_travel_advice_summary_displayed(url, summary) + reload_url_until_status_code(url, 200) + reload_url_until_match(url, :has_text?, ignore_quotes_regex(summary)) + end + def self.included(base) if SignonHelpers::use_signon? default_permissions = %w[gds_editor] diff --git a/spec/travel_advice_publisher/creating_draft_spec.rb b/spec/travel_advice_publisher/creating_draft_spec.rb index a95188ac..cbdeac9b 100644 --- a/spec/travel_advice_publisher/creating_draft_spec.rb +++ b/spec/travel_advice_publisher/creating_draft_spec.rb @@ -33,8 +33,7 @@ def when_i_create_a_draft_of_chad def then_i_can_preview_it_on_draft_gov_uk url = find_link("Preview saved version")[:href] - reload_url_until_status_code(url, 200) - reload_url_until_match(url, :has_text?, ignore_quotes_regex(summary)) + reload_until_travel_advice_summary_displayed(url, summary) @window = window_opened_by { click_link("Preview saved version") } within_window(@window) do diff --git a/spec/travel_advice_publisher/creating_live_spec.rb b/spec/travel_advice_publisher/creating_live_spec.rb index 2cba820b..5ea7a3b3 100644 --- a/spec/travel_advice_publisher/creating_live_spec.rb +++ b/spec/travel_advice_publisher/creating_live_spec.rb @@ -31,8 +31,7 @@ def when_i_create_a_live_edition_of_malta def then_i_can_view_it_on_gov_uk url = find_link("view")[:href] - reload_url_until_status_code(url, 200) - reload_url_until_match(url, :has_text?, ignore_quotes_regex(summary)) + reload_until_travel_advice_summary_displayed(url, summary) @window = window_opened_by { click_link("view") } within_window(@window) do diff --git a/spec/travel_advice_publisher/upload_attachments_spec.rb b/spec/travel_advice_publisher/upload_attachments_spec.rb index 2a1342b6..3a71cbca 100644 --- a/spec/travel_advice_publisher/upload_attachments_spec.rb +++ b/spec/travel_advice_publisher/upload_attachments_spec.rb @@ -33,7 +33,7 @@ def and_i_upload_files_to_it def then_i_can_view_these_files_on_draft_gov_uk url = find_link("Preview saved version")[:href] - reload_url_until_status_code(url, 200) + reload_until_travel_advice_summary_displayed(url, summary) window = window_opened_by { click_link("Preview saved version") } within_window(window) do