Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support rendering of service manual document types #2583

Merged
merged 13 commits into from
Feb 8, 2023
138 changes: 138 additions & 0 deletions test/integration/service_manual_guide_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
require "test_helper"
require "pry"

class ServiceManualGuideTest < ActionDispatch::IntegrationTest
test "shows the time it was saved if it hasn't been published yet" do
now = "2015-10-10T09:00:00+00:00"
last_saved_at = "2015-10-10T08:55:00+00:00"

travel_to(now) do
example = simulate_example_as_first_edition_on_draft_stack(
govuk_content_schema_example(
"service_manual_guide",
"service_manual_guide",
updated_at: last_saved_at,
),
)
base_path = example.fetch("base_path")
stub_content_store_has_item(base_path, example)
visit base_path

within(".app-change-history") do
assert page.has_content?("5 minutes ago")
end
end
end

test "shows the time it was published if it has been published" do
travel_to Time.zone.local(2015, 10, 10, 0, 0, 0) do
setup_and_visit_example("service_manual_guide", "service_manual_guide")

within(".app-change-history") do
assert page.has_content?("about 16 hours ago")
end
end
end

test "service manual guide shows content owners" do
setup_and_visit_example("service_manual_guide", "service_manual_guide")

within(".app-metadata--heading") do
assert page.has_link?("Agile delivery community")
end
end

test "the breadcrumb contains the topic" do
setup_and_visit_example("service_manual_guide", "service_manual_guide")

within(".gem-c-breadcrumbs") do
assert page.has_link?("Service manual")
assert page.has_link?("Agile")
end
end

test "service manual guide does not show published by" do
setup_and_visit_example("service_manual_guide", "service_manual_guide_community")

within(".gem-c-metadata") do
assert_not 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(".app-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")

assert_not page.has_css?(".app-page-header__summary")
end

test "displays a link to give feedback" do
setup_and_visit_example("service_manual_guide", "service_manual_guide")

assert page.has_link?("Give feedback about this page")
end

test "displays the published date of the most recent change" do
setup_and_visit_example("service_manual_guide", "service_manual_guide")

within(".app-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(".app-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(".app-change-history__past") do
assert page.has_content? "This is another change"
assert page.has_content? "Guidance first published"
end
end

test "omits the previous history if there is only one change" do
setup_and_visit_example(
"service_manual_guide",
"service_manual_guide",
"details" => {
"change_history" => [
{
"public_timestamp" => "2015-09-01T08:17:10+00:00",
"note" => "Guidance first published",
},
],
},
)

assert_not page.has_content? "Show all page updates"
assert_not page.has_css? ".app-change-history__past"
end

test "omits the latest change and previous change if the guide has no history" do
setup_and_visit_example(
"service_manual_guide",
"service_manual_guide",
"details" => {
"change_history" => [],
},
)

assert_not page.has_content? "Last update:"
assert_not page.has_content? "Show all page updates"
assert_not page.has_css? ".app-change-history__past"
end
end
53 changes: 53 additions & 0 deletions test/integration/service_manual_homepage_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
require "test_helper"

class ServiceManualHomepageTest < ActionDispatch::IntegrationTest
test "the homepage displays the introductory text" do
setup_and_visit_example("service_manual_homepage", "service_manual_homepage")

assert page.has_content? <<~TEXT.squish
Helping teams to create and run great public services that meet the
Service Standard.
TEXT
end

test "the homepage includes a feedback link" do
setup_and_visit_example("service_manual_homepage", "service_manual_homepage")

assert page.has_content?(
"Contact the Service Manual team with any comments or questions.",
)

assert page.has_link? "Contact the Service Manual team", href: "/contact/govuk"
end

test "the homepage includes the titles and descriptions of associated topics" do
setup_and_visit_example("service_manual_homepage", "service_manual_homepage")

assert page.has_content? "Agile delivery\nHow to work in an agile way: principles, tools and governance."
assert page.has_link? "Agile delivery", href: "/service-manual/agile-delivery"
end

test "the homepage includes a link to the service standard" do
setup_and_visit_example("service_manual_homepage", "service_manual_homepage")

assert page.has_content? <<~TEXT.squish
The Service Standard provides the principles of building a good service.
This manual explains what teams can do to build great services that will
meet the standard.
TEXT

assert page.has_link? "Service Standard", href: "/service-manual/service-standard"
end

test "the homepage includes a link to the communities of practise" do
setup_and_visit_example("service_manual_homepage", "service_manual_homepage")

assert page.has_content? <<~TEXT.squish
You can view the communities of practice to find more learning
resources, see who has written the guidance in the manual and connect
with digital people like you from across government.
TEXT

assert page.has_link? "communities of practice", href: "/service-manual/communities"
end
end
50 changes: 50 additions & 0 deletions test/integration/service_manual_phase_label_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
require "test_helper"

class PhaseLabelTest < ActionDispatch::IntegrationTest
test "renders custom message for service manual guide pages" do
guide = content_store_has_schema_example(
"service_manual_guide",
"service_manual_guide",
phase: "beta",
)

visit guide["base_path"]

assert page.has_content?("Contact the Service Manual team")
end

test "renders custom message for service manual homepage" do
homepage = content_store_has_schema_example(
"service_manual_homepage",
"service_manual_homepage",
)

visit homepage["base_path"]

assert page.has_content?("Contact the Service Manual team")
end

test "alpha phase label is displayed for a guide in phase 'alpha'" do
guide = content_store_has_schema_example(
"service_manual_guide",
"service_manual_guide",
phase: "alpha",
)

visit guide["base_path"]

assert page.has_content?("alpha")
end

test "No phase label is displayed for a guide without a phase field" do
guide = content_store_has_schema_example(
"service_manual_guide",
"service_manual_guide",
phase: nil,
)

visit guide["base_path"]

assert_not page.has_content?("Contact the Service Manual team")
end
end
8 changes: 8 additions & 0 deletions test/integration/service_manual_search_redirect_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require "test_helper"

class ServiceManualSearchRedirectTest < ActionDispatch::IntegrationTest
test "the legacy search URL redirects to /search and retains parameters" do
get "/service-manual/search?q=bananas"
assert_redirected_to "/search?filter_manual=%2Fservice-manual&q=bananas"
end
end
73 changes: 73 additions & 0 deletions test/integration/service_manual_service_standard_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
require "test_helper"
require "pry"

class ServiceManualServiceStandardTest < ActionDispatch::IntegrationTest
test "service standard page has a title, summary and intro" do
setup_and_visit_example(
"service_manual_service_standard",
"service_manual_service_standard",
title: "Service Standard",
description: "The Service Standard is a set of 14 criteria.",
details: {
body: "All public facing transactional services must meet the standard.",
},
)

assert page.has_css?(".gem-c-title__text", text: "Service Standard"), "No title found"
assert page.has_css?(".app-page-header__summary", text: "The Service Standard is a set of 14 criteria"), "No description found"
assert page.has_css?(".app-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"
assert page.has_link?("Read more about point 1", href: "/service-manual/service-standard/understand-user-needs"), "Link not found"
end

within(points[1]) do
assert page.has_content?("2. Do ongoing user research"), "Point not found"
assert page.has_content?(/Put a plan in place/), "Description not found"
assert page.has_link?("Read more about point 2", href: "/service-manual/service-standard/do-ongoing-user-research"), "Link not found"
end

within(points[2]) do
assert page.has_content?("3. Have a multidisciplinary team"), "Point not found"
assert page.has_content?(/Put in place a sustainable multidisciplinary/), "Description not found"
assert page.has_link?("Read more about point 3", href: "/service-manual/service-standard/have-a-multidisciplinary-team"), "Link not found"
end
end

test "each point has an anchor tag so that they can be linked to externally" do
setup_and_visit_example("service_manual_service_standard", "service_manual_service_standard")

within("#criterion-1") do
assert page.has_content?("1. Understand user needs"), "Anchor is incorrect"
end

within("#criterion-2") do
assert page.has_content?("2. Do ongoing user research"), "Anchor is incorrect"
end

within("#criterion-3") do
assert page.has_content?("3. Have a multidisciplinary team"), "Anchor is incorrect"
end
end

test "it includes a link to subscribe for email alerts" do
setup_and_visit_example("service_manual_service_standard", "service_manual_service_standard")

assert page.has_link?(
"email",
href: "/email-signup?link=/service-manual/service-standard",
)
end

def points
find_all(".app-service-standard-point")
end
end
71 changes: 71 additions & 0 deletions test/integration/service_manual_topic_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
require "test_helper"

class ServiceManualTopicTest < ActionDispatch::IntegrationTest
setup do
@topic_example = GovukSchemas::Example.find("service_manual_topic", example_name: "service_manual_topic")
end

test "it uses topic description as meta description" do
stub_content_store_has_item("/service-manual/test-topic", @topic_example.to_json)

visit "/service-manual/test-topic"

assert page.has_css?('meta[name="description"]', visible: false)
tag = page.find 'meta[name="description"]', visible: false
assert_equal @topic_example["description"], tag["content"]
end

test "it doesn't write a meta description if there is none" do
@topic_example.delete("description")
stub_content_store_has_item("/service-manual/test-topic", @topic_example.to_json)

visit "/service-manual/test-topic"

assert_not page.has_css?('meta[name="description"]', visible: false)
end

test "it lists communities in the sidebar" do
setup_and_visit_example("service_manual_topic", "service_manual_topic")

within(".related-communities") do
assert page.has_link?(
"Agile delivery community",
href: "/service-manual/communities/agile-delivery-community",
)
assert page.has_link?(
"User research community",
href: "/service-manual/communities/user-research-community",
)
end
end

test "it doesn't display content in accordian if not eligible" do
setup_and_visit_example("service_manual_topic", "service_manual_topic")

assert_not page.has_css?(".gem-c-accordion")
end

test "it displays content using an accordian if eligible" do
content_item = govuk_content_schema_example("service_manual_topic", "service_manual_topic")
third_linked_item = { content_id: SecureRandom.uuid, title: "linky", base_path: "/basey" }
third_group = { name: "Group 3", description: "The third group", content_ids: [third_linked_item[:content_id]] }

content_item["links"]["linked_items"] << third_linked_item
content_item["details"]["groups"] << third_group
content_item["details"]["visually_collapsed"] = true

stub_content_store_has_item(content_item["base_path"], content_item)
visit content_item["base_path"]

assert page.has_css?(".gem-c-accordion")
end

test "it includes a link to subscribe for email alerts" do
setup_and_visit_example("service_manual_topic", "service_manual_topic")

assert page.has_link?(
"email",
href: "/email-signup?link=/service-manual/test-expanded-topic",
)
end
end
112 changes: 112 additions & 0 deletions test/integration/service_standard_service_toolkit_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
require "test_helper"

class ServiceManualServiceToolkitTest < ActionDispatch::IntegrationTest
test "the service toolkit can be visited" do
setup_and_visit_example("service_manual_service_toolkit", "service_manual_service_toolkit")

assert page.has_title? "Service Toolkit"
end

test "the service toolkit does not include the new style feedback form" do
setup_and_visit_example("service_manual_service_toolkit", "service_manual_service_toolkit")

assert_not page.has_css?(".improve-this-page"),
"Improve this page component should not be present on the page"
end

test "the service toolkit displays the introductory hero" do
setup_and_visit_example("service_manual_service_toolkit", "service_manual_service_toolkit")

assert page.has_content? <<~TEXT.chomp
Design and build government services
All you need to design, build and run services that meet government standards.
TEXT
end

test "the homepage includes both collections" do
setup_and_visit_example("service_manual_service_toolkit", "service_manual_service_toolkit")

assert_equal 2, collections.length, "Expected to find 2 collections"
end

test "the homepage includes the titles for both collections" do
setup_and_visit_example("service_manual_service_toolkit", "service_manual_service_toolkit")

within(the_first_collection) do
assert page.has_content? "Standards"
end

within(the_second_collection) do
assert page.has_content? "Buying"
end
end

test "the homepage includes the descriptions for both collections" do
setup_and_visit_example("service_manual_service_toolkit", "service_manual_service_toolkit")

within(the_first_collection) do
assert page.has_content? "Meet the standards for government services"
end

within(the_second_collection) do
assert page.has_content? "Extra skills, people and technology to help build your service"
end
end

test "the homepage includes the links from all collections" do
setup_and_visit_example(
"service_manual_service_toolkit",
"service_manual_service_toolkit",
details: {
collections: [
{
title: "Standards",
description: "Meet the standards for government services",
links: [
{
title: "Service Standard",
url: "https://www.gov.uk/service-manual/service-standard",
description: "",
},
],
},
{
title: "Buying",
description: "Skills and technology for building digital services",
links: [
{
title: "Digital Marketplace",
url: "https://www.gov.uk/digital-marketplace",
description: "",
},
],
},
],
},
)

within(the_first_collection) do
assert page.has_link? "Service Standard",
href: "https://www.gov.uk/service-manual/service-standard"
end

within(the_second_collection) do
assert page.has_link? "Digital Marketplace",
href: "https://www.gov.uk/digital-marketplace"
end
end

private

def collections
find_all(".app-collection")
end

def the_first_collection
collections[0]
end

def the_second_collection
collections[1]
end
end