Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

Commit

Permalink
Fix almost all of the tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
injms committed Sep 11, 2019
1 parent 875fb69 commit 5fc75c3
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 71 deletions.
1 change: 0 additions & 1 deletion app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ $govuk-compatibility-govukelements: true;
@import "modules/hero";
@import "modules/link-unit";
@import "modules/main-service-manual";
@import "modules/metadata";
@import "modules/notice";
@import "modules/page-contents";
@import "modules/page-header";
Expand Down
9 changes: 2 additions & 7 deletions app/assets/stylesheets/modules/_govspeak-wrapper.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,12 @@
.govuk-govspeak p,
.govuk-govspeak ol,
.govuk-govspeak ul {
line-height: 1.45;
// govspeak margin bottom is 20px
margin-bottom: $gutter-half;
}

.govuk-govspeak h2 {
margin-top: 15px;
padding-top: 15px;
// govspeak margin-top is 45px
@include media(tablet) {
margin-top: 15px;
padding-top: 30px;
}
@extend %govuk-heading-m;
}
}
31 changes: 0 additions & 31 deletions app/assets/stylesheets/modules/_metadata.scss

This file was deleted.

8 changes: 3 additions & 5 deletions app/assets/stylesheets/modules/_service-standard-point.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.app-c-service-standard-point {
$gutter-tablet: (govuk-spacing(6) * 1.5); // 45px

border-top: 1px solid $govuk-border-colour;
margin-top: govuk-spacing(5);
padding-top: govuk-spacing(5);
Expand All @@ -13,7 +11,7 @@
margin-left: govuk-spacing(6);

@include govuk-media-query($from: tablet) {
margin-left: $gutter-tablet;
margin-left: govuk-spacing(8);
}
}

Expand All @@ -22,7 +20,7 @@
margin-left: (0 - govuk-spacing(6));

@include govuk-media-query($from: tablet) {
margin-left: -$gutter-tablet;
margin-left: -govuk-spacing(8);
}
}

Expand All @@ -31,7 +29,7 @@
margin-left: govuk-spacing(6);

@include govuk-media-query($from: tablet) {
margin-left: $gutter-tablet;
margin-left: govuk-spacing(8);
}
}

Expand Down
16 changes: 9 additions & 7 deletions app/views/content_items/guide.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
<div class="govuk-grid-row">

<div class="govuk-grid-column-two-thirds">
<div class="page-header">
<div class="app-c-page-header">

<%= render "govuk_publishing_components/components/title", {
context: @content_item.category_title,
title: @content_item.title,
margin_bottom: 8
} %>
<% if @content_item.show_description? %>
<p class="govuk-body-l">
<p class="govuk-body-l app-c-page-header__summary">
<%= @content_item.description %>
</p>
<% end %>
Expand All @@ -40,9 +40,9 @@

<!-- Metadata-->
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<div class="govuk-grid-column-two-thirds app-c-metadata--heading">
<%= render "govuk_publishing_components/components/metadata", {
last_updated: time_ago_in_words(@content_item.visible_updated_at),
last_updated: "#{time_ago_in_words(@content_item.visible_updated_at)} ago",
from: @content_item.content_owners.map { |content_owner|
link_to(content_owner.title, content_owner.href)
}
Expand Down Expand Up @@ -88,11 +88,13 @@
<% end %>
</div>
<% if @content_item.previous_changes.present? %>
<p><a href="#full-history" data-controls="full-history" data-expanded="false" role="button" aria-controls="full-history" aria-expanded="false">+ Show all page updates (<%= @content_item.previous_changes.length + 1 %>)</a></p>
<ol id="full-history" class="app-c-change-history__past js-hidden" aria-live="polite" role="region">
<p class="govuk-!-margin-bottom-3">
<a href="#full-history" data-controls="full-history" data-toggled-text="- Hide all page updates (<%= @content_item.previous_changes.length %>)" data-expanded="false" role="button" aria-controls="full-history" aria-expanded="false">+ Show all page updates (<%= @content_item.previous_changes.length %>)</a>
</p>
<ol id="full-history" class="app-c-change-history__past govuk-list js-hidden" aria-live="polite" role="region">
<% @content_item.previous_changes.each do |previous_change| %>
<li>
<%= render partial: 'shared/change_history', locals: {change: previous_change} %>
<%= render partial: 'shared/change_history', locals: { change: previous_change, compressed: true} %>
</li>
<% end %>
</ol>
Expand Down
6 changes: 4 additions & 2 deletions app/views/content_items/service_standard.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<div class="app-c-page-header govuk-!-margin-top-3 govuk-!-margin-bottom-3">
<h1 class="govuk-heading-xl app-c-page-header__heading"><%= @content_item.title %></h1>
<p class="govuk-body-l govuk-!-margin-bottom-7">
<%= render "govuk_publishing_components/components/title", {
title: @content_item.title,
} %>
<p class="govuk-body-l govuk-!-margin-bottom-7 app-c-page-header__summary">
<%= @content_item.content_item["description"] %>
</p>
<div class="app-c-page-header__intro govuk-!-padding-bottom-3">
Expand Down
9 changes: 7 additions & 2 deletions app/views/shared/_change_history.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<% time = change.public_timestamp %>
<time datetime="<%= time.iso8601 %>" class="govuk-heading-m govuk-!-margin-bottom-1">
<%
time = change.public_timestamp
compressed |= false
time_class = compressed ? 'govuk-heading-s' : 'govuk-heading-m'
time_class << ' govuk-!-margin-bottom-1'
%>
<time datetime="<%= time.iso8601 %>" class="<%= time_class %>">
<%= l time, format: :short_ordinal %>
</time>
<p class="govuk-body-s app-c-change-history__change-note">
Expand Down
23 changes: 12 additions & 11 deletions test/integration/guide_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'test_helper'
require 'pry'

class GuideTest < ActionDispatch::IntegrationTest
test "shows the time it was saved if it hasn't been published yet" do
Expand All @@ -17,7 +18,7 @@ class GuideTest < ActionDispatch::IntegrationTest
content_store_has_item(base_path, example)
visit base_path

within('.metadata') do
within('.app-c-metadata--heading') do
assert page.has_content?('5 minutes ago')
end
end
Expand All @@ -27,7 +28,7 @@ class GuideTest < ActionDispatch::IntegrationTest
travel_to Time.zone.local(2015, 10, 10, 0, 0, 0) do
setup_and_visit_example('service_manual_guide', 'service_manual_guide')

within('.metadata') do
within('.app-c-metadata--heading') do
assert page.has_content?('about 16 hours ago')
end
end
Expand All @@ -36,7 +37,7 @@ class GuideTest < ActionDispatch::IntegrationTest
test "service manual guide shows content owners" do
setup_and_visit_example('service_manual_guide', 'service_manual_guide')

within('.metadata') do
within('.app-c-metadata--heading') do
assert page.has_link?('Agile delivery community')
end
end
Expand All @@ -53,23 +54,23 @@ class GuideTest < ActionDispatch::IntegrationTest
test "service manual guide does not show published by" do
setup_and_visit_example('service_manual_guide', 'service_manual_guide_community')

within('.metadata') do
within('.gem-c-metadata') do
refute page.has_content?('Published by')
end
end

test "displays the description for a point" do
setup_and_visit_example('service_manual_guide', 'point_page')

within('.page-header__summary') do
within('.app-c-page-header__summary') do
assert page.has_content?('Research to develop a deep knowledge of who the service users are')
end
end

test "does not display the description for a normal guide" do
setup_and_visit_example('service_manual_guide', 'service_manual_guide')

refute page.has_css?('.page-header__summary')
refute page.has_css?('.app-c-page-header__summary')
end

test "displays a link to give feedback" do
Expand All @@ -81,23 +82,23 @@ class GuideTest < ActionDispatch::IntegrationTest
test 'displays the published date of the most recent change' do
setup_and_visit_example('service_manual_guide', 'service_manual_guide')

within('.change-history') do
within('.app-c-change-history') do
assert page.has_content? 'Last update: 9 October 2015'
end
end

test 'displays the most recent change history for a guide' do
setup_and_visit_example('service_manual_guide', 'service_manual_guide')

within('.change-history') do
within('.app-c-change-history') do
assert page.has_content? 'This is our latest change'
end
end

test 'displays the change history for a guide' do
setup_and_visit_example('service_manual_guide', 'service_manual_guide')

within('.change-history__past') do
within('.app-c-change-history__past') do
assert page.has_content? 'This is another change'
assert page.has_content? 'Guidance first published'
end
Expand All @@ -115,7 +116,7 @@ class GuideTest < ActionDispatch::IntegrationTest
})

refute page.has_content? 'Show all page updates'
refute page.has_css? '.change-history__past'
refute page.has_css? '.app-c-change-history__past'
end

test 'omits the latest change and previous change if the guide has no history' do
Expand All @@ -126,6 +127,6 @@ class GuideTest < ActionDispatch::IntegrationTest

refute page.has_content? 'Last update:'
refute page.has_content? 'Show all page updates'
refute page.has_css? '.change-history__past'
refute page.has_css? '.app-c-change-history__past'
end
end
9 changes: 4 additions & 5 deletions test/integration/service_standard_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'test_helper'
require 'pry'

class ServiceStandardTest < ActionDispatch::IntegrationTest
test "service standard page has a title, summary and intro" do
Expand All @@ -12,16 +13,14 @@ class ServiceStandardTest < ActionDispatch::IntegrationTest
}
)

assert page.has_css?(".page-header__title", text: "Service Standard"), "No title found"
assert page.has_css?(".page-header__summary", text: "The Service Standard is a set of 14 criteria"), "No description found"
assert page.has_css?(".page-header__intro", text: "All public facing transactional services must meet the standard."), "No body found"
assert page.has_css?(".gem-c-title__text", text: "Service Standard"), "No title found"
assert page.has_css?(".app-c-page-header__summary", text: "The Service Standard is a set of 14 criteria"), "No description found"
assert page.has_css?(".app-c-page-header__intro", text: "All public facing transactional services must meet the standard."), "No body found"
end

test "service standard page has points" do
setup_and_visit_example('service_manual_service_standard', 'service_manual_service_standard')

assert_equal 3, points.length

within(points[0]) do
assert page.has_content?("1. Understand user needs"), "Point not found"
assert page.has_content?(/Research to develop a deep knowledge/), "Description not found"
Expand Down

0 comments on commit 5fc75c3

Please sign in to comment.