-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #326 from alphagov/add_template_tests
Add some integration tests for the existing templates
- Loading branch information
Showing
11 changed files
with
280 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.9.3-p392 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require_relative "../../integration_test_helper" | ||
|
||
class ChromelessTest < ActionDispatch::IntegrationTest | ||
|
||
should "render the template" do | ||
visit "/templates/chromeless.html.erb" | ||
|
||
within "head", :visible => :all do | ||
assert page.has_selector?("title", :text => "GOV.UK - The best place to find government services and information", :visible => :all) | ||
|
||
assert page.has_selector?("link[href='/static/header-footer-only.css']", :visible => :all) | ||
end | ||
|
||
within "body" do | ||
assert page.has_selector?("#global-cookie-message") | ||
|
||
assert page.has_selector?("#wrapper") | ||
|
||
within "footer" do | ||
refute page.has_selector?(".footer-categories") | ||
|
||
assert page.has_selector?(".footer-meta") | ||
end | ||
|
||
assert page.has_selector?("script[src='/static/libs/jquery/jquery-1.7.2.js']", :visible => :all) | ||
assert page.has_selector?("script[src='/static/header-footer-only.js']", :visible => :all) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require_relative "../../integration_test_helper" | ||
|
||
class Error4XXTest < ActionDispatch::IntegrationTest | ||
|
||
should "render the 404 template" do | ||
visit "/templates/404.html.erb" | ||
|
||
assert page.has_selector?("html.error.error-40X") | ||
within "head", :visible => :all do | ||
assert page.has_selector?("title", :text => "Page not found - 404 - GOV.UK", :visible => :all) | ||
|
||
assert page.has_selector?("link[href='/static/application.css']", :visible => :all) | ||
|
||
assert page.has_selector?("script[src='/static/libs/jquery/jquery-1.7.2.js']", :visible => :all) | ||
assert page.has_selector?("script[src='/static/application.js']", :visible => :all) | ||
end | ||
|
||
within "body.mainstream.error" do | ||
within "header#global-header" do | ||
assert page.has_selector?("form#search") | ||
end | ||
|
||
assert page.has_selector?("#global-cookie-message") | ||
assert page.has_selector?("#user-satisfaction-survey") | ||
assert page.has_selector?("#global-breadcrumb") | ||
|
||
within "#wrapper" do | ||
assert page.has_selector?("h1", :text => "This page cannot be found") | ||
|
||
assert page.has_selector?(".report-a-problem") | ||
end | ||
|
||
within "footer" do | ||
assert page.has_selector?(".footer-categories") | ||
|
||
assert page.has_selector?(".footer-meta") | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require_relative "../../integration_test_helper" | ||
|
||
class Error5XXTest < ActionDispatch::IntegrationTest | ||
|
||
should "render the 500 template" do | ||
visit "/templates/500.html.erb" | ||
|
||
assert page.has_selector?("html.error.error-50X") | ||
within "head", :visible => :all do | ||
assert page.has_selector?("title", :text => "Sorry, we are experiencing technical difficulties (500 error) - GOV.UK", :visible => :all) | ||
|
||
assert page.has_selector?("link[href='/static/application.css']", :visible => :all) | ||
|
||
assert page.has_selector?("script[src='/static/libs/jquery/jquery-1.7.2.js']", :visible => :all) | ||
assert page.has_selector?("script[src='/static/application.js']", :visible => :all) | ||
end | ||
|
||
within "body.mainstream.error" do | ||
within "header#global-header" do | ||
assert page.has_selector?("form#search") | ||
end | ||
|
||
assert page.has_selector?("#global-cookie-message") | ||
assert page.has_selector?("#user-satisfaction-survey") | ||
assert page.has_selector?("#global-breadcrumb") | ||
|
||
within "#wrapper" do | ||
assert page.has_selector?("h1", :text => "Sorry, we are experiencing technical difficulties") | ||
end | ||
|
||
within "footer" do | ||
assert page.has_selector?(".footer-categories") | ||
|
||
assert page.has_selector?(".footer-meta") | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require_relative "../../integration_test_helper" | ||
|
||
class HeaderFooterOnlyTest < ActionDispatch::IntegrationTest | ||
|
||
should "render the template" do | ||
visit "/templates/header_footer_only.html.erb" | ||
|
||
within "head", :visible => :all do | ||
assert page.has_selector?("title", :text => "GOV.UK - The best place to find government services and information", :visible => :all) | ||
|
||
assert page.has_selector?("link[href='/static/header-footer-only.css']", :visible => :all) | ||
end | ||
|
||
within "body" do | ||
within "header#global-header" do | ||
assert page.has_selector?("form#search") | ||
end | ||
|
||
assert page.has_selector?("#global-cookie-message") | ||
assert page.has_selector?("#user-satisfaction-survey") | ||
assert page.has_selector?("#global-breadcrumb") | ||
|
||
assert page.has_selector?("#wrapper") | ||
|
||
within "footer" do | ||
assert page.has_selector?(".footer-categories") | ||
|
||
assert page.has_selector?(".footer-meta") | ||
end | ||
|
||
assert page.has_selector?("script[src='/static/libs/jquery/jquery-1.7.2.js']", :visible => :all) | ||
assert page.has_selector?("script[src='/static/header-footer-only.js']", :visible => :all) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require_relative "../../integration_test_helper" | ||
|
||
class HomepageTest < ActionDispatch::IntegrationTest | ||
|
||
should "render the template" do | ||
visit "/templates/homepage.html.erb" | ||
|
||
within "head", :visible => :all do | ||
assert page.has_selector?("title", :text => "GOV.UK - The best place to find government services and information", :visible => :all) | ||
|
||
assert page.has_selector?("link[href='/static/application.css']", :visible => :all) | ||
|
||
assert page.has_selector?("script[src='/static/libs/jquery/jquery-1.7.2.js']", :visible => :all) | ||
assert page.has_selector?("script[src='/static/application.js']", :visible => :all) | ||
end | ||
|
||
within "body" do | ||
within "header#global-header" do | ||
assert page.has_selector?("form#search") | ||
end | ||
|
||
assert page.has_selector?("#global-cookie-message") | ||
assert page.has_selector?("#user-satisfaction-survey") | ||
refute page.has_selector?("#global-breadcrumb") | ||
|
||
assert page.has_selector?("#wrapper") | ||
|
||
within "footer" do | ||
assert page.has_selector?(".footer-categories") | ||
|
||
assert page.has_selector?(".footer-meta") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require_relative "../../integration_test_helper" | ||
|
||
class NonLayoutTemplatesTest < ActionDispatch::IntegrationTest | ||
def template_file(name) | ||
Rails.root.join("app", "views", "root", "#{name}.html.erb") | ||
end | ||
|
||
%w( | ||
beta_notice | ||
campaign | ||
proposition_menu | ||
related.raw | ||
report_a_problem.raw | ||
).each do |template| | ||
should "not add a layout to the #{template} snippet" do | ||
get "/templates/#{template}.html.erb" | ||
|
||
refute_match '<html', last_response.body | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require_relative "../../integration_test_helper" | ||
|
||
class WrapperTest < ActionDispatch::IntegrationTest | ||
|
||
should "render the template" do | ||
visit "/templates/wrapper.html.erb" | ||
|
||
within "head", :visible => :all do | ||
assert page.has_selector?("title", :text => "GOV.UK - The best place to find government services and information", :visible => :all) | ||
|
||
assert page.has_selector?("link[href='/static/application.css']", :visible => :all) | ||
|
||
assert page.has_selector?("script[src='/static/libs/jquery/jquery-1.7.2.js']", :visible => :all) | ||
assert page.has_selector?("script[src='/static/application.js']", :visible => :all) | ||
end | ||
|
||
within "body" do | ||
within "header#global-header" do | ||
assert page.has_selector?("form#search") | ||
end | ||
|
||
assert page.has_selector?("#global-cookie-message") | ||
assert page.has_selector?("#user-satisfaction-survey") | ||
assert page.has_selector?("#global-breadcrumb") | ||
|
||
assert page.has_selector?("#wrapper") | ||
|
||
within "footer" do | ||
assert page.has_selector?(".footer-categories") | ||
|
||
assert page.has_selector?(".footer-meta") | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require_relative "../../integration_test_helper" | ||
|
||
class WrapperWithJSLastTest < ActionDispatch::IntegrationTest | ||
|
||
should "render the template" do | ||
visit "/templates/wrapper_with_js_last.html.erb" | ||
|
||
within "head", :visible => :all do | ||
assert page.has_selector?("title", :text => "GOV.UK - The best place to find government services and information", :visible => :all) | ||
|
||
assert page.has_selector?("link[href='/static/application.css']", :visible => :all) | ||
end | ||
|
||
within "body" do | ||
within "header#global-header" do | ||
assert page.has_selector?("form#search") | ||
end | ||
|
||
assert page.has_selector?("#global-cookie-message") | ||
assert page.has_selector?("#user-satisfaction-survey") | ||
assert page.has_selector?("#global-breadcrumb") | ||
|
||
assert page.has_selector?("#wrapper") | ||
|
||
within "footer" do | ||
assert page.has_selector?(".footer-categories") | ||
|
||
assert page.has_selector?(".footer-meta") | ||
end | ||
|
||
assert page.has_selector?("script[src='/static/libs/jquery/jquery-1.7.2.js']", :visible => :all) | ||
assert page.has_selector?("script[src='/static/application.js']", :visible => :all) | ||
end | ||
end | ||
end |