Skip to content

Commit

Permalink
Merge pull request #237 from alphagov/revert-234-fix-smokey-tests
Browse files Browse the repository at this point in the history
Revert "Restore Poltergeist and fix Smokey tests"
  • Loading branch information
dazahern committed Feb 8, 2017
2 parents d607057 + 5336fab commit 696966c
Show file tree
Hide file tree
Showing 31 changed files with 193 additions and 156 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Expand Up @@ -5,8 +5,8 @@ gem "rake", "0.9.2.2"
gem "rspec", "2.11.0"
gem "minitest", "5.8.4"
gem "cucumber", "1.3.20"
gem "capybara", "~> 2.12.0"
gem "poltergeist", "1.13.0"
gem "capybara", "~> 2.0"
gem "capybara-mechanize"

gem "rest-client", "1.6.7"
gem "nokogiri", "1.5.5"
41 changes: 27 additions & 14 deletions Gemfile.lock
@@ -1,37 +1,49 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.5.0)
public_suffix (~> 2.0, >= 2.0.2)
addressable (2.4.0)
builder (3.2.2)
capybara (2.12.0)
capybara (2.10.1)
addressable
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
cliver (0.3.2)
capybara-mechanize (1.5.0)
capybara (~> 2.4, >= 2.4.4)
mechanize (~> 2.7.0)
cucumber (1.3.20)
builder (>= 2.1.2)
diff-lcs (>= 1.1.3)
gherkin (~> 2.12)
multi_json (>= 1.7.5, < 2.0)
multi_test (>= 0.1.2)
diff-lcs (1.1.3)
domain_name (0.5.20160826)
unf (>= 0.0.5, < 1.0.0)
gherkin (2.12.2)
multi_json (~> 1.3)
http-cookie (1.0.3)
domain_name (~> 0.5)
mechanize (2.7.3)
domain_name (~> 0.5, >= 0.5.1)
http-cookie (~> 1.0)
mime-types (~> 2.0)
net-http-digest_auth (~> 1.1, >= 1.1.1)
net-http-persistent (~> 2.5, >= 2.5.2)
nokogiri (~> 1.4)
ntlm-http (~> 0.1, >= 0.1.1)
webrobots (>= 0.0.9, < 0.2)
mime-types (2.99.3)
minitest (5.8.4)
multi_json (1.12.1)
multi_test (0.1.2)
net-http-digest_auth (1.4)
net-http-persistent (2.9.4)
nokogiri (1.5.5)
ntlm-http (0.1.1)
plek (1.11.0)
poltergeist (1.13.0)
capybara (~> 2.1)
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
public_suffix (2.0.5)
rack (2.0.1)
rack-test (0.6.3)
rack (>= 1.0)
Expand All @@ -46,22 +58,23 @@ GEM
rspec-expectations (2.11.3)
diff-lcs (~> 1.1.3)
rspec-mocks (2.11.3)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.2)
webrobots (0.1.2)
xpath (2.0.0)
nokogiri (~> 1.3)

PLATFORMS
ruby

DEPENDENCIES
capybara (~> 2.12.0)
capybara (~> 2.0)
capybara-mechanize
cucumber (= 1.3.20)
minitest (= 5.8.4)
nokogiri (= 1.5.5)
plek (= 1.11.0)
poltergeist (= 1.13.0)
rake (= 0.9.2.2)
rest-client (= 1.6.7)
rspec (= 2.11.0)
Expand Down
4 changes: 2 additions & 2 deletions features/asset_manager.feature
Expand Up @@ -5,13 +5,13 @@ Feature: Asset Manager
Scenario: check an asset can be loaded
Given I am testing "asset-manager"
And I am an authenticated API client
When I request "/assets/513a0efbed915d425e000002"
When I visit "/assets/513a0efbed915d425e000002"
Then I should get a 200 status code
And I should see "120613_Albania_Travel_Advice_WEB_Ed2_jpeg.jpg"

@normal
Scenario: check an asset can be served
Given I am testing "static"
When I request "/media/513a0efbed915d425e000002/120613_Albania_Travel_Advice_WEB_Ed2_jpeg.jpg"
When I visit "/media/513a0efbed915d425e000002/120613_Albania_Travel_Advice_WEB_Ed2_jpeg.jpg"
Then I should get a 200 status code
And I should get a content length of "212880"
2 changes: 1 addition & 1 deletion features/assets.feature
Expand Up @@ -3,5 +3,5 @@ Feature: Assets
@high
Scenario: Assets are being served
Given I am testing "assets"
When I request "/__canary__"
When I visit "/__canary__"
Then I should get a 200 status code
6 changes: 2 additions & 4 deletions features/calculators.feature
Expand Up @@ -4,9 +4,7 @@ Feature: Calculators app
Scenario: Accessing the child benefit tax calculator
Given I am testing through the full stack
And I force a varnish cache miss

When I visit "/child-benefit-tax-calculator"
Then I should see "Child Benefit tax calculator"

Then I should get a 200 status code
When I visit "/child-benefit-tax-calculator/main"
Then I should see "Child Benefit tax calculator"
Then I should get a 200 status code
3 changes: 1 addition & 2 deletions features/calendars.feature
Expand Up @@ -20,5 +20,4 @@ Feature: Calendars
@normal
Scenario: check bank holidays JSON format is consistent
Given I am testing through the full stack
When I request "/bank-holidays.json"
Then JSON is returned
Then I should see a consistent JSON format for the path "/bank-holidays.json"
2 changes: 1 addition & 1 deletion features/content_api.feature
Expand Up @@ -4,6 +4,6 @@ Feature: Content API
Scenario: (Public) Content API availability
Given I am testing through the full stack
And I force a varnish cache miss
When I request "/api/vehicle-tax.json"
When I visit "/api/vehicle-tax.json"
Then I should get a 200 status code
And I should see "Tax your vehicle"
4 changes: 3 additions & 1 deletion features/efg.feature
@@ -1,5 +1,8 @@
Feature: EFG

Background:
Given I am testing in an EFG context

@notintegration
@normal
Scenario: Requires authenticated user to view lenders
Expand All @@ -16,6 +19,5 @@ Feature: EFG
@notintegration
@normal
Scenario: Can log in
Given I cannot see the logout button
When I try to login as a valid EFG user
Then I should be on the EFG post-login page
6 changes: 3 additions & 3 deletions features/frontend.feature
Expand Up @@ -6,7 +6,7 @@ Feature: Frontend

@normal
Scenario: check robots.txt
When I request "/robots.txt"
When I visit "/robots.txt"
Then I should get a 200 status code
Then I should see "User-agent:"

Expand All @@ -32,7 +32,7 @@ Feature: Frontend

@normal
Scenario: check homepage content type & charset
When I request "/"
When I visit "/"
Then I should get a "Content-Type" header of "text/html; charset=utf-8"

@normal
Expand Down Expand Up @@ -67,7 +67,7 @@ Feature: Frontend
@normal
Scenario: check campaign pages load
When I visit "/workplacepensions"
Then I should be at a location path of "/workplace-pensions"
Then I should get a 200 status code

@normal
Scenario: check browse page load, and links
Expand Down
5 changes: 0 additions & 5 deletions features/javascript_errors.feature

This file was deleted.

3 changes: 1 addition & 2 deletions features/licensing.feature
Expand Up @@ -5,7 +5,6 @@ Feature: Licensing
Given I am testing "licensing"
And I am testing through the full stack
And I force a varnish cache miss
And I am ignoring JavaScript errors
Then I should be able to visit:
| Path |
| /apply-for-a-licence/test-licence/westminster/apply-1 |
Expand All @@ -18,7 +17,7 @@ Feature: Licensing
And I am benchmarking
And I am testing through the full stack
And I force a varnish cache miss
When I request "/apply-for-a-licence/forms/bury/test-licence/9999-7-1,0-1"
When I visit "/apply-for-a-licence/forms/bury/test-licence/9999-7-1,0-1"
Then the elapsed time should be less than 10 seconds

@normal @notintegration
Expand Down
8 changes: 5 additions & 3 deletions features/private_frontend.feature
@@ -1,8 +1,10 @@
Feature: Private Frontend

@normal
Scenario: check private frontend requires auth
Background:
Given I am testing "private-frontend"
And I am not an authenticated user
When I try to request "/"

@normal
Scenario: check private frontend requires auth
When I try to visit "/"
Then I should get a 401 status code
13 changes: 9 additions & 4 deletions features/step_definitions/ab_testing_steps.rb
Expand Up @@ -16,17 +16,22 @@
end

Then(/^I am assigned to a test bucket$/) do
ab_cookie = page.driver.cookies["ABTest-Example"]
@ab_cookie_value = ab_cookie.value
ab_cookies = @response.headers[:set_cookie]
.select { |h| h.start_with? "ABTest-Example=" }
assert_equal 1, ab_cookies.length,
"Expected response to set exactly one A/B test cookie"

ab_cookie = ab_cookies[0]
@ab_cookie_value = /ABTest-Example=([^;]*);/.match(ab_cookie)[1]

assert @ab_cookie_value == "A" || @ab_cookie_value == "B",
"Expected A/B cookie to have value 'A' or 'B' but got '#{@ab_cookie_value}'"

refute_nil ab_cookie.expires, "A/B cookie has no expiry time"
assert ab_cookie.include?("expires="), "A/B cookie has no expiry time"
end

Then(/^I can see the bucket I am assigned to$/) do
bucket = ab_bucket(page.body)
bucket = ab_bucket(@response.body)
assert bucket == "A" || bucket == "B",
"Expected A/B bucket to be 'A' or 'B', but got '#{bucket}'"

Expand Down
11 changes: 9 additions & 2 deletions features/step_definitions/calendar_steps.rb
@@ -1,5 +1,12 @@
require 'json'

Then /^JSON is returned$/ do
JSON.parse(@response.body).class.should == Hash
Then /^I should see a consistent JSON format for the path "([^"]*)"$/ do |path|
json = get_request "#{@host}#{path}", cache_bust: @bypass_varnish
json = JSON.parse(json)
assert json["england-and-wales"]
assert json["england-and-wales"]["events"]
assert json["england-and-wales"]["events"].length
result = json["england-and-wales"]["events"].first
assert result["title"]
assert result["date"]
end
4 changes: 2 additions & 2 deletions features/step_definitions/cookie_steps.rb
@@ -1,6 +1,6 @@
Then /^I should receive a "([a-z0-9_]+)" cookie which is "([a-zA-Z]+)"$/ do |cookie_name, cookie_property|
header = page.response_headers['Set-Cookie']
assert header.to_s.start_with?(cookie_name), "No cookie called #{cookie_name} is being set"
header = page.response_headers['set-cookie']
assert header.start_with?(cookie_name), "No cookie called #{cookie_name} is being set"

property_matches = header.match /; #{cookie_property}(;|$)/
assert !property_matches.nil?, "The cookie #{cookie_name} does not have property #{cookie_property}"
Expand Down
8 changes: 4 additions & 4 deletions features/step_definitions/draft_environment_steps.rb
@@ -1,17 +1,17 @@
When /^I attempt to go to a case study$/ do
visit_path "government/case-studies/epic-cic"
visit "government/case-studies/epic-cic"
end

When /^I attempt to visit "(.*?)"$/ do |path|
visit_path path
visit path
end

When /^I attempt to visit a CMA case$/ do
visit_path "cma-cases/japan-tobacco-international-e-lites"
visit "cma-cases/japan-tobacco-international-e-lites"
end

When /^I attempt to visit a manual$/ do
visit_path "guidance/content-design"
visit "guidance/content-design"
end

Then /^I should be prompted to log in$/ do
Expand Down
19 changes: 11 additions & 8 deletions features/step_definitions/efg_steps.rb
@@ -1,30 +1,33 @@
Given /^I cannot see the logout button$/ do
page.has_selector?("#logout").should == false
Given /^I am testing in an EFG context$/ do
# Not sure if there is a better way to do this?
page.driver.browser.agent.add_auth(efg_base_url, ENV['AUTH_USERNAME'], ENV['AUTH_PASSWORD'])
end

When /^I try to access the list of lenders$/ do
visit_path "#{efg_base_url}/lenders"
visit "#{efg_base_url}/lenders"
end

When /^I try to login as a valid EFG user$/ do
assert ENV["EFG_USERNAME"] && ENV["EFG_PASSWORD"], "Please ensure that the EFG user credentials are available in the environment"

# Need to do it this way to comply with CSRF protection
visit_path "#{efg_base_url}/users/sign_in"
visit "#{efg_base_url}/users/sign_in"
fill_in "Username", :with => ENV["EFG_USERNAME"]
fill_in "Password", :with =>ENV["EFG_PASSWORD"]
click_button "Sign In"
end

When /^I visit the EFG home page$/ do
visit_path "#{efg_base_url}"
visit "#{efg_base_url}"
end

Then /^I should be on the EFG home page$/ do
page.has_selector?("#user_username").should == true
page.has_selector?("#user_password").should == true
page.has_selector?("#user_username").should == true # username input field
page.has_selector?("#user_password").should == true # password input field
end

Then /^I should be on the EFG post-login page$/ do
page.has_selector?("#logout").should == true
page.has_selector?(".alert-success").should == true # Signed in successfully message
page.has_selector?("#welcome_message").should == true # Welcome back, first_name
page.has_selector?("#logout").should == true # page has a logout link
end
2 changes: 1 addition & 1 deletion features/step_definitions/finder_frontend_steps.rb
@@ -1,3 +1,3 @@
Then /^I should see an input field to search$/ do
page.body.should have_field('keywords')
@response.body.should have_field('keywords')
end
4 changes: 2 additions & 2 deletions features/step_definitions/frontend_steps.rb
@@ -1,9 +1,9 @@
When /^I click on the section "(.*?)"$/ do |section_name|
link_href = Nokogiri::HTML.parse(page.body).at_xpath("//h3[text()='#{section_name}']/../@href")
link_href = Nokogiri::HTML.parse(@response.body).at_xpath("//h3[text()='#{section_name}']/../@href")
link_href.should_not == nil
step "I visit \"#{link_href.value}\""
end

Then /^I should see an input field for postcode$/ do
page.body.should have_field('postcode')
@response.body.should have_field('postcode')
end
2 changes: 1 addition & 1 deletion features/step_definitions/licensing.rb
@@ -1,4 +1,4 @@
When /^I login to Licensify$/ do
visit_path "https://licensify-admin.#{ENV['GOVUK_APP_DOMAIN']}/login"
visit "https://licensify-admin.#{ENV['GOVUK_APP_DOMAIN']}/login"
click_button 'Login'
end
13 changes: 0 additions & 13 deletions features/step_definitions/search_steps.rb

This file was deleted.

2 changes: 1 addition & 1 deletion features/step_definitions/sitemap_steps.rb
@@ -1,6 +1,6 @@
When /^I get the sitemap index$/ do
step "I visit \"/sitemap.xml\""
@sitemap_doc = Nokogiri.XML(page.body)
@sitemap_doc = Nokogiri.XML(@response.body)
@sitemap_links = @sitemap_doc.xpath("/xmlns:sitemapindex/xmlns:sitemap/xmlns:loc")
end

Expand Down

0 comments on commit 696966c

Please sign in to comment.