Skip to content

Commit

Permalink
Attempt to use status_code - driver dependent
Browse files Browse the repository at this point in the history
  • Loading branch information
karlbaker02 committed Jun 11, 2021
1 parent fd0e410 commit 85e7e89
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
38 changes: 21 additions & 17 deletions features/step_definitions/publisher_steps.rb
@@ -1,3 +1,9 @@
module Status
OK = 200
NOT_FOUND = 404
GONE = 410
end

When "I go to add an artefact" do
click_on "Add artefact"
expect(page).to have_content("New artefact")
Expand All @@ -14,8 +20,11 @@
click_on "Preview"

wait_until do
visit page.current_url
page.has_no_text?(:all, /not found/i)
status = get_status_code do
visit page.current_url
end

status != Status::NOT_FOUND
end
end

Expand Down Expand Up @@ -61,8 +70,11 @@
click_on "View this on the GOV.UK website"

wait_until do
visit_path publication_url
page.has_no_text?(:all, /not found/i)
status = get_status_code do
visit_path publication_url
end

status != Status::NOT_FOUND
end
end

Expand All @@ -80,8 +92,11 @@
expect(page).to have_content("Content unpublished")

wait_until do
visit_path publication_url
page.has_text?(:all, /gone/i)
status = get_status_code do
visit_path publication_url
end

status == Status::GONE
end
end

Expand All @@ -91,23 +106,12 @@ def parameterize(str)

def publication_title
@publication_title ||= "Smokey test draft place #{$smokey_run_id}"
@publication_title
end

def publication_path
@publication_path ||= "/#{parameterize(publication_title)}"
@publication_path
end

def publication_url
@publication_url ||= "#{ENV['GOVUK_WEBSITE_ROOT']}#{publication_path}"
@publication_url
end

def page_contains_no_error?(error)
visit page.current_url

if page.has_no_content?(error)
return true
end
end
6 changes: 6 additions & 0 deletions features/step_definitions/smokey_steps.rb
Expand Up @@ -321,3 +321,9 @@ def cache_hits_value(response)
raise "Couldn't find X-Cache-Hits header in response"
end
end

def get_status_code
$proxy.new_har
yield
$proxy.har.entries.first.response.status
end

0 comments on commit 85e7e89

Please sign in to comment.