diff --git a/README.md b/README.md
index d7f91c91df..b29bfadfa1 100644
--- a/README.md
+++ b/README.md
@@ -30,18 +30,18 @@ Transaction start pages:
### Licence finders
-* https://www.gov.uk/premises-licence
-* https://www.gov.uk/temporary-events-notice
-* https://www.gov.uk/apply-skip-permit
-* https://www.gov.uk/street-collection-licence
-* https://www.gov.uk/zoo-licence
-* https://www.gov.uk/premises-licence-scotland
-* https://www.gov.uk/house-to-house-collection-licence
-* https://www.gov.uk/public-charitable-collection-permit-scotland
-* https://www.gov.uk/late-hours-catering-licence-scotland
-* https://www.gov.uk/food-business-registration
-* https://www.gov.uk/cooling-tower-notification
-* https://www.gov.uk/performing-animals-registration
+* https://www.gov.uk/find-licences/premises-licence
+* https://www.gov.uk/find-licences/temporary-events-notice
+* https://www.gov.uk/find-licences/apply-skip-permit
+* https://www.gov.uk/find-licences/street-collection-licence
+* https://www.gov.uk/find-licences/zoo-licence
+* https://www.gov.uk/find-licences/premises-licence-scotland
+* https://www.gov.uk/find-licences/house-to-house-collection-licence
+* https://www.gov.uk/find-licences/public-charitable-collection-permit-scotland
+* https://www.gov.uk/find-licences/late-hours-catering-licence-scotland
+* https://www.gov.uk/find-licences/food-business-registration
+* https://www.gov.uk/find-licences/cooling-tower-notification
+* https://www.gov.uk/find-licences/performing-animals-registration
### Calendars
diff --git a/app/controllers/licence_controller.rb b/app/controllers/licence_controller.rb
deleted file mode 100644
index 4ac94438c0..0000000000
--- a/app/controllers/licence_controller.rb
+++ /dev/null
@@ -1,133 +0,0 @@
-class LicenceController < ContentItemsController
- include Previewable
- include Cacheable
- include SplitPostcodeSupport
-
- helper_method :postcode, :licence_details
-
- INVALID_POSTCODE = "invalidPostcodeFormat".freeze
- NO_LOCATION_ERROR = "validPostcodeNoLocation".freeze
- NO_MATCHING_AUTHORITY = "noLaMatch".freeze
- NO_LOCATIONS_API_MATCH = "fullPostcodeNoLocationsApiMatch".freeze
-
- def start
- if publication.continuation_link.present?
- render :continues_on
- elsif licence_details.single_licence_authority_present?
- redirect_to licence_authority_path(slug: params[:slug], authority_slug: licence_details.authority["slug"])
- elsif licence_details.multiple_licence_authorities_present? && authority_choice_submitted?
- redirect_to licence_authority_path(slug: params[:slug], authority_slug: CGI.escape(params[:authority][:slug]))
- end
- end
-
- def find
- @location_error = location_error
- if @location_error
- @postcode = params[:postcode]
- return render :start
- end
-
- return redirect_to licence_authority_path(slug: params[:slug], authority_slug: local_authority_slug) if locations_api_response.single_authority?
-
- @addresses = address_list
- @options = options
- @change_path = licence_path(slug: params[:slug])
- @onward_path = licence_multiple_authorities_path(slug: params[:slug])
- render :multiple_authorities
- end
-
- def multiple_authorities
- redirect_to licence_authority_path(slug: params[:slug], authority_slug: params[:authority_slug])
- end
-
- def authority
- if publication.continuation_link.present?
- redirect_to licence_path(slug: params[:slug])
- elsif licence_details.local_authority_specific?
- # TODO: Shoud not override @license_details here
- @licence_details = LicenceDetailsPresenter.new(licence_details_from_api_for_local_authority, params[:authority_slug], params[:interaction])
- end
- end
-
-private
-
- def publication_class
- LicencePresenter
- end
-
- def licence_details
- @licence_details ||= LicenceDetailsPresenter.new(licence_details_from_api, params["authority_slug"], params[:interaction])
- end
-
- def licence_details_from_api(local_authority_code = nil)
- return {} if publication.continuation_link.present?
-
- begin
- GdsApi.licence_application.details_for_licence(publication.licence_identifier, local_authority_code)
- rescue GdsApi::HTTPErrorResponse => e
- return {} if e.code == 404
-
- raise
- end
- end
-
- def licence_details_from_api_for_local_authority
- local_authority_code = local_authority_code_from_slug
- raise RecordNotFound unless local_authority_code
-
- licence_details_from_api(local_authority_code)
- end
-
- def local_authority_code_from_slug
- local_authority_results = Frontend.local_links_manager_api.local_authority(params[:authority_slug])
- snac = local_authority_results.dig("local_authorities", 0, "snac")
- return snac if snac
-
- local_authority_results.dig("local_authorities", 0, "gss")
- end
-
- def authority_choice_submitted?
- params[:authority] && params[:authority][:slug]
- end
-
- def location_error
- return LocationError.new(INVALID_POSTCODE) if locations_api_response.invalid_postcode? || locations_api_response.blank_postcode?
- return LocationError.new(NO_LOCATIONS_API_MATCH) if locations_api_response.location_not_found?
- return LocationError.new(NO_MATCHING_AUTHORITY) unless local_authority_slug
- end
-
- def locations_api_response
- @locations_api_response ||= fetch_location(postcode)
- end
-
- def fetch_location(postcode)
- if postcode.present?
- begin
- local_custodian_codes = Frontend.locations_api.local_custodian_code_for_postcode(postcode)
- rescue GdsApi::HTTPNotFound
- local_custodian_codes = []
- rescue GdsApi::HTTPClientError => e
- error = e
- end
- end
- LocationsApiPostcodeResponse.new(postcode, local_custodian_codes, error)
- end
-
- def authority_results
- @authority_results ||= Frontend.local_links_manager_api.local_authority_by_custodian_code(locations_api_response.local_custodian_codes.first)
- rescue GdsApi::HTTPNotFound
- @authority_results = {}
- end
-
- def local_authority_slug
- @local_authority_slug ||= begin
- return nil unless locations_api_response.location_found?
-
- authority_results.dig("local_authorities", 0, "slug")
- end
- end
-
- def postcode
- PostcodeSanitizer.sanitize(params[:postcode])
- end
-end
diff --git a/app/presenters/licence_presenter.rb b/app/presenters/licence_presenter.rb
deleted file mode 100644
index 49d8f15cc8..0000000000
--- a/app/presenters/licence_presenter.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-class LicencePresenter < ContentItemPresenter
- PASS_THROUGH_DETAILS_KEYS = %i[
- continuation_link
- licence_identifier
- licence_overview
- licence_short_description
- will_continue_on
- ].freeze
-
- PASS_THROUGH_DETAILS_KEYS.each do |key|
- define_method key do
- details[key.to_s] if details
- end
- end
-end
diff --git a/app/views/licence/_action.html.erb b/app/views/licence/_action.html.erb
deleted file mode 100644
index 7616aa968a..0000000000
--- a/app/views/licence/_action.html.erb
+++ /dev/null
@@ -1,34 +0,0 @@
-<%= render "govuk_publishing_components/components/heading", text: "How to #{action}", margin_bottom: 4 %>
-
-<% if licence_details.authority["actions"][action].size > 1 %>
-
There is more than one online form available for this licence:
-
-
- <% licence_details.authority["actions"][action].each_with_index do |link, i| %>
- <%= link_to link['description'], "#form-#{i+1}", class: "govuk-link" %>
- <% end %>
-
-<% end %>
-
-<% licence_details.authority["actions"][action].each_with_index do |link, i| %>
-
- <%= i+1 %>. <%= link['description'] %>
-
- <%= render "govuk_publishing_components/components/govspeak", {
- } do %>
- <%= simple_format link['introduction'] %>
- <% end %>
-
- <% if link['uses_licensify'] %>
- <%= render "govuk_publishing_components/components/button",
- text: "Apply online",
- start: true,
- href: link['url'],
- margin_bottom: true %>
- <% elsif link['uses_authority_url'] %>
- <%= render partial: 'authority_url', locals: {action: action, index: i} %>
- <% else %>
- <%= render partial: 'licensify_unavailable' %>
- <% end %>
-
-<% end %>
diff --git a/app/views/licence/_authority_details.html.erb b/app/views/licence/_authority_details.html.erb
deleted file mode 100644
index cc52076f52..0000000000
--- a/app/views/licence/_authority_details.html.erb
+++ /dev/null
@@ -1,109 +0,0 @@
-<%
- ga4_type = content_item_hash["schema_name"].gsub("_", " ")
-
- ga4_form_complete_attributes = {
- event_name: "form_complete",
- action: "complete",
- type: ga4_type,
- text: "From #{licence_details.authority['name']}",
- tool_name: publication.title,
- }.to_json
-
- ga4_information_click_attributes = {
- event_name: "information_click",
- action: "information click",
- type: ga4_type,
- tool_name: publication.title,
- }.to_json
-
- ga4_change_response_attributes = {
- event_name: "form_change_response",
- action: "change response",
- type: ga4_type,
- tool_name: publication.title
- }.to_json
-
- ga4_data_modules = "ga4-link-tracker"
-
- if !licence_details.action
- # Only trigger a GA4 form complete if the user is currently on the first contents link.
- trigger_ga4_form_complete = true
- ga4_data_modules << " ga4-auto-tracker"
- end
-
-%>
-
-From <%= licence_details.authority['name'] %>
-
-
-
- <% if licence_details.action %>
- <%= link_to "Overview", licence_authority_path(publication.slug, licence_details.authority["slug"]), class: "govuk-link" %>
- <% else %>
- Overview
- <% end %>
- <% licence_details.authority['actions'].keys.uniq.each do |action| %>
- <% if licence_details.action == action %>
- <%= "How to #{action}" %>
- <% else %>
- <%= link_to "How to #{action}", licence_authority_path(publication.slug, licence_details.authority["slug"], action), class: "govuk-link" %>
- <% end %>
- <% end %>
-
-
-
-
- data-ga4-auto="<%= ga4_form_complete_attributes %>"
- <% end %>
- data-ga4-link="<%= ga4_information_click_attributes %>"
- data-ga4-track-links-only
- data-ga4-set-indexes
->
-
- <% if licence_details.action.present? %>
- <% if licence_details.uses_licensify %>
- <%= render :partial => "action", :locals => {:action => licence_details.action } %>
- <% elsif licence_details.uses_authority_url %>
- <%= render :partial => 'authority_url', :locals => {:action => licence_details.action, :index => 0} %>
- <% else %>
- <%= render :partial => 'licensify_unavailable' %>
- <% end %>
- <% elsif publication.licence_overview.present? %>
- <%= render "govuk_publishing_components/components/heading", text: "Overview", margin_bottom: 4 %>
- <%= render "govuk_publishing_components/components/govspeak", {
- } do %>
- <%= raw publication.licence_overview %>
- <% end %>
- <% end %>
-
- <% if licence_details.local_authority_specific? or licence_details.multiple_licence_authorities_present? %>
-
- <% end %>
-
-
diff --git a/app/views/licence/_authority_url.html.erb b/app/views/licence/_authority_url.html.erb
deleted file mode 100644
index 7cb5479cbf..0000000000
--- a/app/views/licence/_authority_url.html.erb
+++ /dev/null
@@ -1,3 +0,0 @@
-<%= render "govuk_publishing_components/components/warning_text", {
- text: sanitize("To obtain this licence, you need to contact the authority directly. To continue, go to #{link_to(licence_details.authority["name"], licence_details.authority.dig("actions", action)[index]["url"], class: "govuk-link")}.")
-} %>
diff --git a/app/views/licence/_licensify_unavailable.html.erb b/app/views/licence/_licensify_unavailable.html.erb
deleted file mode 100644
index a0b1812155..0000000000
--- a/app/views/licence/_licensify_unavailable.html.erb
+++ /dev/null
@@ -1,16 +0,0 @@
-<%
- ga4_attributes = {
- event_name: "form complete",
- type: "licence",
- text: "You cannot apply for this licence online",
- action: "complete",
- tool_name: publication.title,
- }.to_json
-%>
-
- <%= render "govuk_publishing_components/components/warning_text", {
- text: sanitize("You cannot apply for this licence online. #{link_to('Contact your local council', '/find-local-council', class: "govuk-link")}.")
- } %>
-
diff --git a/app/views/licence/authority.html.erb b/app/views/licence/authority.html.erb
deleted file mode 100644
index d575606b39..0000000000
--- a/app/views/licence/authority.html.erb
+++ /dev/null
@@ -1,14 +0,0 @@
-<%= render layout: 'shared/base_page', locals: {
- main_class: ("multi-page" if licence_details.authority),
- context: "Licence",
- title: publication.title,
- publication: publication,
- edition: @edition,
-} do %>
-
- <% if licence_details.present? && licence_details.has_any_actions? %>
- <%= render partial: 'authority_details' %>
- <% else %>
- <%= render partial: 'licensify_unavailable' %>
- <% end %>
-<% end %>
diff --git a/app/views/licence/continues_on.html.erb b/app/views/licence/continues_on.html.erb
deleted file mode 100644
index 7d585056a6..0000000000
--- a/app/views/licence/continues_on.html.erb
+++ /dev/null
@@ -1,35 +0,0 @@
-<%= render layout: 'shared/base_page', locals: {
- context: "Licence",
- title: publication.title,
- publication: publication,
- edition: @edition,
-} do %>
-
-
-
-
- <%= render "govuk_publishing_components/components/heading", text: "Apply for this licence", margin_bottom: 4 %>
-
-
- <% info_text = "#{t('formats.transaction.on')} #{publication.will_continue_on}" if publication.will_continue_on.present? %>
- <%= render "govuk_publishing_components/components/button",
- text: "Start now",
- rel: "external",
- start: true,
- info_text: info_text,
- margin_bottom: true,
- href: publication.continuation_link %>
-
-
-
-
-
- <%= render "govuk_publishing_components/components/heading", text: "Overview", margin_bottom: 4 %>
- <%= render "govuk_publishing_components/components/govspeak", {
- } do %>
- <%= raw publication.licence_overview %>
- <% end %>
-
-
-
-<% end %>
diff --git a/app/views/licence/multiple_authorities.html.erb b/app/views/licence/multiple_authorities.html.erb
deleted file mode 100644
index 6ebb3d807c..0000000000
--- a/app/views/licence/multiple_authorities.html.erb
+++ /dev/null
@@ -1,39 +0,0 @@
-<%= render layout: "shared/base_page", locals: {
- main_class: ("multi-page" if licence_details.authority),
- context: "Licence",
- title: publication.title,
- publication: publication,
- edition: @edition,
-} do %>
-
- <%= @postcode %> <%= link_to t("formats.licence.change"), @change_path, class: "govuk-link" %>
-
-
- <%= form_tag(@onward_path, method: :get) do -%>
- <% if @addresses.count > 6 %>
- <%= render "govuk_publishing_components/components/select", {
- id: "authority_slug",
- label: t("formats.local_transaction.select_address"),
- options: @options
- } %>
- <% else %>
- <%= render "govuk_publishing_components/components/radio", {
- id: "authority_slug",
- name: "authority_slug",
- heading: t("formats.local_transaction.select_address"),
- heading_size: "s",
- items: @options
- } %>
- <% end %>
-
- <%= render "govuk_publishing_components/components/button", {
- text: t("continue"),
- data_attributes: {
- module: "gem-track-click",
- track_category: "",
- track_action: "",
- track_label: ""
- }
- } %>
- <% end %>
-<% end %>
diff --git a/app/views/licence/start.html.erb b/app/views/licence/start.html.erb
deleted file mode 100644
index d2f98d369c..0000000000
--- a/app/views/licence/start.html.erb
+++ /dev/null
@@ -1,53 +0,0 @@
-<%= render layout: 'shared/base_page', locals: {
- main_class: ("multi-page" if licence_details.authority),
- context: "Licence",
- title: publication.title,
- publication: publication,
- edition: @edition,
-} do %>
-
-
- <% if licence_details.present? %>
-
- <% if licence_details.local_authority_specific? %>
-
- <%= render "govuk_publishing_components/components/heading", text: "Apply for this licence" %>
- <%= render partial: 'location_form',
- locals: {
- format: 'licence',
- publication_format: 'licence',
- postcode: postcode,
- margin_top: @location_error ? 5 : 0,
- publication_title: publication.title,
- } %>
-
- <% else %>
- <% # TODO: replace this with the radio component %>
-
Please choose an authority to apply for the licence from.
-
The authority you select will not affect the type of licence you apply for.
- <%= form_tag publication.slug, method: 'get' do %>
-
- <% licence_details.authorities.each do |authority| %>
- <%= radio_button :authority, :slug, authority['slug'] %><%= label :authority, :slug, authority['name'], :value => authority['slug'] %>
- <% end %>
-
- <%= render "govuk_publishing_components/components/button", text: "Get started", start: true, margin_bottom: true %>
- <% end %>
- <% end %>
-
- <% else %>
- <%= render "govuk_publishing_components/components/warning_text", {
- text: sanitize("You cannot apply for this licence online. #{link_to('Contact your local council', '/find-local-council', class: "govuk-link")}.")
- } %>
- <% end %>
-
-
- <%= render "govuk_publishing_components/components/heading", text: "Overview", margin_bottom: 4 %>
- <%= render "govuk_publishing_components/components/govspeak", {
- } do %>
- <%= raw publication.licence_overview %>
- <% end %>
-
-
-
-<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index bdc244b679..993253b597 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -82,14 +82,6 @@
get ":slug/:part", to: redirect("/%{slug}") # Support for places that were once a format with parts
end
- # Licence pages
- constraints FormatRoutingConstraint.new("licence") do
- get ":slug", to: "licence#start", as: "licence"
- post ":slug", to: "licence#find" # Support for postcode submission which we treat as confidential data
- get ":slug/multiple_authorities" => "licence#multiple_authorities", as: "licence_multiple_authorities"
- get ":slug/:authority_slug(/:interaction)", to: "licence#authority", as: "licence_authority"
- end
-
# Calendar pages
constraints(format: /(json|ics)/) do
get "/bank-holidays/ni", to: redirect("/bank-holidays/northern-ireland.%{format}")
diff --git a/test/functional/licence_controller_test.rb b/test/functional/licence_controller_test.rb
deleted file mode 100644
index a2a8752619..0000000000
--- a/test/functional/licence_controller_test.rb
+++ /dev/null
@@ -1,95 +0,0 @@
-require "test_helper"
-require "gds_api/test_helpers/locations_api"
-require "gds_api/test_helpers/local_links_manager"
-require "gds_api/test_helpers/licence_application"
-
-class LicenceControllerTest < ActionController::TestCase
- include GdsApi::TestHelpers::LocationsApi
- include GdsApi::TestHelpers::LocalLinksManager
- include GdsApi::TestHelpers::LicenceApplication
- include LocationHelpers
-
- context "GET start" do
- context "for live content" do
- setup do
- content_store_has_page("licence-to-kill")
- end
-
- should "set the cache expiry headers" do
- get :start, params: { slug: "licence-to-kill" }
-
- honours_content_store_ttl
- end
- end
- end
-
- context "POST to find" do
- setup do
- @payload = {
- base_path: "/licence-to-kill",
- document_type: "licence",
- format: "licence",
- schema_name: "licence",
- title: "Licence to kill",
- public_updated_at: "2012-10-02T12:30:33.483Z",
- description: "Descriptive licence text.",
- details: {
- licence_identifier: "1071-5-1",
- licence_overview: "You only live twice, Mr Bond.\n",
- },
- }
-
- stub_content_store_has_item("/licence-to-kill", @payload)
- end
-
- context "loading the licence edition when posting a location" do
- setup do
- stub_licence_exists(
- "1071-5-1",
- "isLocationSpecific" => true,
- "isOfferedByCounty" => false,
- "geographicalAvailability" => %w[England Wales],
- "issuingAuthorities" => [],
- )
- end
-
- context "for an English local authority" do
- setup do
- configure_locations_api_and_local_authority("ST10 4DB", %w[staffordshire staffordshire-moorlands], 3435)
-
- post :find, params: { slug: "licence-to-kill", postcode: "ST10 4DB" }
- end
-
- should "redirect to the slug for the lowest level authority" do
- assert_redirected_to "/licence-to-kill/staffordshire-moorlands"
- end
- end
-
- context "for a Northern Irish local authority" do
- setup do
- configure_locations_api_and_local_authority("BT1 5GS", %w[belfast], 8132)
-
- post :find, params: { slug: "licence-to-kill", postcode: "BT1 5GS" }
- end
-
- should "redirect to the slug for the lowest level authority" do
- assert_redirected_to "/licence-to-kill/belfast"
- end
- end
- end
- end
-
- context "GET authority" do
- context "for live content" do
- setup do
- content_store_has_page("licence-to-kill")
- end
-
- should "set the cache expiry headers" do
- get :authority, params: { slug: "licence-to-kill", authority_slug: "secret-service" }
-
- honours_content_store_ttl
- end
- end
- end
-end
diff --git a/test/integration/licence_test.rb b/test/integration/licence_test.rb
deleted file mode 100644
index 38a94a4904..0000000000
--- a/test/integration/licence_test.rb
+++ /dev/null
@@ -1,1548 +0,0 @@
-require "integration_test_helper"
-require "gds_api/test_helpers/locations_api"
-require "gds_api/test_helpers/local_links_manager"
-require "gds_api/test_helpers/licence_application"
-
-class LicenceTest < ActionDispatch::IntegrationTest
- include GdsApi::TestHelpers::LocationsApi
- include GdsApi::TestHelpers::LocalLinksManager
- include GdsApi::TestHelpers::LicenceApplication
- include LocationHelpers
-
- context "given a location specific licence" do
- setup do
- configure_locations_api_and_local_authority("SW1A 1AA", %w[westminster], 5990)
- stub_local_links_manager_does_not_have_an_authority("not-a-valid-council-name")
-
- @payload = {
- base_path: "/licence-to-kill",
- document_type: "licence",
- format: "licence",
- phase: "beta",
- schema_name: "licence",
- title: "Licence to kill",
- public_updated_at: "2012-10-02T12:30:33.483Z",
- description: "Descriptive licence text.",
- details: {
- lgsl_code: 461,
- lgil_code: 8,
- licence_identifier: "1071-5-1",
- licence_overview: "You only live twice, Mr Bond.\n",
- },
- }
-
- stub_content_store_has_item("/licence-to-kill", @payload)
-
- stub_licence_exists(
- "1071-5-1",
- "isLocationSpecific" => true,
- "isOfferedByCounty" => false,
- "geographicalAvailability" => %w[England Wales],
- "issuingAuthorities" => [],
- )
- end
-
- context "when visiting the licence search page" do
- setup do
- visit "/licence-to-kill"
- end
-
- should "render the licence page" do
- assert_equal 200, page.status_code
-
- within "head", visible: :all do
- assert page.has_selector?("title", text: "Licence to kill - GOV.UK", visible: :all)
- end
-
- within "#content" do
- within ".gem-c-title" do
- assert_has_component_title "Licence to kill"
- end
-
- within ".postcode-search-form" do
- assert page.has_field?("Enter a postcode")
- assert_has_button("Find")
- end
-
- assert page.has_no_content?("Please enter a valid full UK postcode.")
-
- within "#overview" do
- assert page.has_content?("Overview")
- assert page.has_content? "You only live twice, Mr Bond."
- end
- end
-
- assert page.has_selector?(".gem-c-phase-banner")
- end
-
- should "add google analytics tags for postcodeSearchStarted" do
- track_category = page.find(".postcode-search-form")["data-track-category"]
- track_action = page.find(".postcode-search-form")["data-track-action"]
-
- assert_equal "postcodeSearch:licence", track_category
- assert_equal "postcodeSearchStarted", track_action
- end
-
- should "add GA4 form submit attributes" do
- data_module = page.find("form")["data-module"]
- expected_data_module = "ga4-form-tracker"
-
- ga4_form_attribute = page.find("form")["data-ga4-form"]
- ga4_expected_object = "{\"event_name\":\"form_submit\",\"action\":\"submit\",\"type\":\"licence\",\"text\":\"Find\",\"section\":\"Enter a postcode\",\"tool_name\":\"Licence to kill\"}"
-
- assert_equal expected_data_module, data_module
- assert_equal ga4_expected_object, ga4_form_attribute
- end
- end
-
- context "when visiting the licence with a valid postcode" do
- context "when it's a unitary or district local authority" do
- setup do
- authorities = [
- {
- "authorityName" => "Westminster City Council",
- "authoritySlug" => "westminster",
- "authorityContact" => {
- "website" => "",
- "email" => "",
- "phone" => "020 7641 6000",
- "address" => "P.O. Box 240\nWestminster City Hall\n\n\nSW1E 6QP",
- },
- "authorityInteractions" => {
- "apply" => [
- {
- "url" => "/licence-to-kill/westminster/apply-1",
- "description" => "Apply for your licence to kill",
- "payment" => "none",
- "introduction" => "This licence is issued shaken, not stirred.",
- "usesLicensify" => true,
- },
- {
- "url" => "/licence-to-kill/westminster/apply-2",
- "description" => "Apply for your licence to hold gadgets",
- "payment" => "none",
- "introduction" => "Q-approval required.",
- "usesLicensify" => true,
- },
- ],
- "renew" => [
- {
- "url" => "/licence-to-kill/westminster/renew-1",
- "description" => "Renew your licence to kill",
- "payment" => "none",
- "introduction" => "",
- "usesLicensify" => true,
- },
- ],
- },
- },
- ]
-
- stub_licence_exists(
- "1071-5-1/00BK",
- "isLocationSpecific" => true,
- "isOfferedByCounty" => false,
- "geographicalAvailability" => %w[England Wales],
- "issuingAuthorities" => authorities,
- )
- visit "/licence-to-kill"
-
- fill_in "postcode", with: "SW1A 1AA"
- click_on "Find"
- end
-
- should "redirect to the appropriate authority slug" do
- assert_equal "/licence-to-kill/westminster", current_path
- end
-
- should "display the authority name" do
- within("#overview") do
- assert page.has_content?("Westminster")
- end
- end
-
- should "show available licence actions" do
- within("#content nav") do
- assert page.has_link? "How to apply", href: "/licence-to-kill/westminster/apply"
- assert page.has_link? "How to renew", href: "/licence-to-kill/westminster/renew"
- end
- end
-
- should "show overview section" do
- within("#overview") do
- assert page.has_content?("You only live twice, Mr Bond.")
- end
- end
-
- context "when visiting a licence action" do
- setup do
- click_link "How to apply"
- end
-
- should "display the page content" do
- assert page.has_content? "Licence to kill"
- assert page.has_selector? "h2", text: "How to apply"
- end
-
- should "display a button to apply for the licence" do
- assert_has_button_as_link(
- "Apply online",
- href: "/licence-to-kill/westminster/apply-1",
- start: true,
- )
- end
- end
-
- should "return a 404 for an invalid action" do
- visit "/licence-to-kill/westminster/blah"
- assert_equal 404, page.status_code
-
- visit "/licence-to-kill/westminster/change"
- assert_equal 404, page.status_code
- end
-
- should "return a 404 for an invalid authority" do
- visit "/licence-to-kill/not-a-valid-council-name"
-
- assert_equal 404, page.status_code
- end
-
- should "add GA4 form complete attributes" do
- data_module = page.find("article")["data-module"]
- expected_data_module = "ga4-link-tracker ga4-auto-tracker"
-
- ga4_auto_attribute = page.find("article")["data-ga4-auto"]
- ga4_expected_object = "{\"event_name\":\"form_complete\",\"action\":\"complete\",\"type\":\"licence\",\"text\":\"From Westminster City Council\",\"tool_name\":\"Licence to kill\"}"
-
- assert_equal expected_data_module, data_module
- assert_equal ga4_expected_object, ga4_auto_attribute
- end
-
- should "not add ga4-auto if you're on a page other than '1. Overview'" do
- visit "/licence-to-kill/westminster/apply"
- data_module = page.find("article")["data-module"]
- expected_data_module = "ga4-link-tracker"
-
- ga4_auto_attribute = page.find("article")["data-ga4-auto"]
-
- assert_equal expected_data_module, data_module
- assert_nil ga4_auto_attribute
- end
-
- should "add GA4 information click attributes" do
- data_module = page.find("article")["data-module"]
- expected_data_module = "ga4-link-tracker ga4-auto-tracker"
-
- ga4_link_attribute = page.find("article")["data-ga4-link"]
- ga4_expected_object = "{\"event_name\":\"information_click\",\"action\":\"information click\",\"type\":\"licence\",\"tool_name\":\"Licence to kill\"}"
-
- assert_equal expected_data_module, data_module
- assert_equal ga4_expected_object, ga4_link_attribute
- end
-
- should "add GA4 change response attributes" do
- ga4_link_attribute = page.find(".contact > p > a")["data-ga4-link"]
- ga4_expected_object = "{\"event_name\":\"form_change_response\",\"action\":\"change response\",\"type\":\"licence\",\"tool_name\":\"Licence to kill\"}"
-
- assert_equal ga4_expected_object, ga4_link_attribute
- end
- end
-
- context "when it's a county local authority" do
- setup do
- @payload = {
- base_path: "/licence-to-thrill",
- document_type: "licence",
- format: "licence",
- schema_name: "licence",
- title: "Licence to thrill",
- public_updated_at: "2012-10-02T12:30:33.483Z",
- description: "Descriptive licence text.",
- details: {
- lgsl_code: 461,
- lgil_code: 8,
- licence_identifier: "999",
- licence_overview: "You only live twice, Mr Bond.\n",
- },
- }
-
- stub_content_store_has_item("/licence-to-thrill", @payload)
-
- configure_locations_api_and_local_authority("HP20 2QF", %w[buckinghamshire], 440)
-
- authorities = [
- {
- "authorityName" => "Buckinghamshire Council",
- "authoritySlug" => "buckinghamshire",
- "authorityContact" => {
- "website" => "",
- "email" => "",
- "phone" => "",
- "address" => "",
- },
- "authorityInteractions" => {
- "apply" => [
- {
- "url" => "/licence-to-thrill/buckinghamshire/apply-1",
- "description" => "Apply for your licence to kill",
- "payment" => "none",
- "introduction" => "This licence is issued shaken, not stirred.",
- "usesLicensify" => true,
- },
- {
- "url" => "/licence-to-thrill/buckinghamshire/apply-2",
- "description" => "Apply for your licence to hold gadgets",
- "payment" => "none",
- "introduction" => "Q-approval required.",
- "usesLicensify" => true,
- },
- ],
- "renew" => [
- {
- "url" => "/licence-to-thrill/buckinghamshire/renew-1",
- "description" => "Renew your licence to kill",
- "payment" => "none",
- "introduction" => "",
- "usesLicensify" => true,
- },
- ],
- },
- },
- ]
-
- stub_licence_exists(
- "999/00BK",
- "isLocationSpecific" => true,
- "isOfferedByCounty" => true,
- "geographicalAvailability" => %w[England Wales],
- "issuingAuthorities" => authorities,
- )
-
- stub_licence_exists(
- "999",
- "isLocationSpecific" => true,
- "isOfferedByCounty" => true,
- "geographicalAvailability" => %w[England Wales],
- "issuingAuthorities" => [],
- )
-
- visit "/licence-to-thrill"
-
- fill_in "postcode", with: "HP20 2QF"
- click_on "Find"
- end
-
- should "redirect to the appropriate authority slug" do
- assert_equal "/licence-to-thrill/buckinghamshire", current_path
- end
-
- should "have an apply link" do
- assert page.has_link? "How to apply", href: "/licence-to-thrill/buckinghamshire/apply"
- end
-
- context "when the local authority doesn't have a SNAC" do
- setup do
- configure_locations_api_and_local_authority("DT11 0SF", %w[dorset], 440, snac: nil, gss: "E06000069")
-
- authorities = [
- {
- "authorityName" => "Dorset Council",
- "authoritySlug" => "dorset",
- "authorityContact" => {
- "website" => "",
- "email" => "",
- "phone" => "",
- "address" => "",
- },
- "authorityInteractions" => {
- "apply" => [
- {
- "url" => "/licence-to-thrill/dorset/apply-1",
- "description" => "Apply for your licence to thrill",
- "payment" => "none",
- "introduction" => "This licence is issued shaken, not stirred.",
- "usesLicensify" => true,
- },
- {
- "url" => "/licence-to-thrill/dorset/apply-2",
- "description" => "Apply for your licence to hold gadgets",
- "payment" => "none",
- "introduction" => "Q-approval required.",
- "usesLicensify" => true,
- },
- ],
- "renew" => [
- {
- "url" => "/licence-to-thrill/dorset/renew-1",
- "description" => "Renew your licence to thrill",
- "payment" => "none",
- "introduction" => "",
- "usesLicensify" => true,
- },
- ],
- },
- },
- ]
-
- stub_licence_exists(
- "999/E06000069",
- "isLocationSpecific" => true,
- "isOfferedByCounty" => true,
- "geographicalAvailability" => %w[England Wales],
- "issuingAuthorities" => authorities,
- )
-
- visit "/licence-to-thrill"
-
- fill_in "postcode", with: "DT11 0SF"
- click_on "Find"
- end
-
- should "redirect to the appropriate authority slug" do
- assert_equal "/licence-to-thrill/dorset", current_path
- end
-
- should "have an apply link" do
- assert page.has_link? "How to apply", href: "/licence-to-thrill/dorset/apply"
- end
- end
- end
-
- context "when there are more than one authority" do
- setup do
- authorities = [
- {
- "authorityName" => "Westminster City Council",
- "authoritySlug" => "westminster",
- "authorityContact" => {
- "website" => "",
- "email" => "",
- "phone" => "020 7641 6000",
- "address" => "P.O. Box 240\nWestminster City Hall\n\n\nSW1E 6QP",
- },
- "authorityInteractions" => {
- "apply" => [
- {
- "url" => "/licence-to-kill/westminster/apply-1",
- "description" => "Apply for your licence to kill",
- "payment" => "none",
- "introduction" => "This licence is issued shaken, not stirred.",
- "usesLicensify" => true,
- },
- ],
- },
- },
- {
- "authorityName" => "Kingsmen Tailors",
- "authoritySlug" => "kingsmen-tailors",
- "authorityContact" => {
- "website" => "",
- "email" => "",
- "phone" => "020 007 007",
- "address" => "Savile Row",
- },
- "authorityInteractions" => {
- "apply" => [
- {
- "url" => "/licence-to-kill/kingsmen-tailors/apply-1",
- "description" => "Apply for your licence to kill",
- "payment" => "none",
- "introduction" => "This licence is issued shaken, not stirred.",
- "usesLicensify" => true,
- },
- ],
- },
- },
-
- ]
-
- stub_licence_exists(
- "1071-5-1/00BK",
- "isLocationSpecific" => true,
- "isOfferedByCounty" => false,
- "geographicalAvailability" => %w[England Wales],
- "issuingAuthorities" => authorities,
- )
-
- visit "/licence-to-kill"
-
- fill_in "postcode", with: "SW1A 1AA"
- click_on "Find"
- end
-
- should "show details for the first authority only" do
- within("#overview") do
- assert page.has_content?("Westminster")
- assert_not page.has_content?("Kingsmen Tailors")
- end
- end
- end
- end
-
- context "when visiting the licence with an invalid formatted postcode" do
- setup do
- stub_locations_api_does_not_have_a_bad_postcode("Not valid")
- visit "/licence-to-kill"
-
- fill_in "postcode", with: "Not valid"
- click_on "Find"
- end
-
- should "remain on the licence page" do
- assert_equal "/licence-to-kill", current_path
- end
-
- should "see an error message" do
- assert page.has_content? "This isn't a valid postcode."
- end
-
- should "re-populate the invalid input" do
- assert page.has_field? "postcode", with: "Not valid"
- end
-
- should "add the GA4 form error attributes" do
- data_module = page.find("#error")["data-module"]
- expected_data_module = "auto-track-event ga4-auto-tracker govuk-error-summary"
-
- ga4_error_attribute = page.find("#error")["data-ga4-auto"]
- ga4_expected_object = "{\"event_name\":\"form_error\",\"action\":\"error\",\"type\":\"licence\",\"text\":\"This isn't a valid postcode.\",\"section\":\"Enter a postcode\",\"tool_name\":\"Licence to kill\"}"
-
- assert_equal expected_data_module, data_module
- assert_equal ga4_expected_object, ga4_error_attribute
- end
- end
-
- context "when visiting the licence with a postcode not present in LocationsApi" do
- setup do
- stub_locations_api_has_no_location("AB1 2AB")
-
- visit "/licence-to-kill"
-
- fill_in "postcode", with: "AB1 2AB"
- click_on "Find"
- end
-
- should "remain on the licence page" do
- assert_equal "/licence-to-kill", current_path
- end
-
- should "see an error message" do
- assert page.has_content? "We couldn't find this postcode."
- end
-
- should "re-populate the invalid input" do
- assert page.has_field? "postcode", with: "AB1 2AB"
- end
- end
-
- context "when visiting the licence with a postcode that has no local authority" do
- setup do
- stub_locations_api_has_location("XM4 5HQ", [{ "local_custodian_code" => 123 }])
-
- stub_local_links_manager_does_not_have_a_custodian_code(123)
-
- visit "/licence-to-kill"
-
- fill_in "postcode", with: "XM4 5HQ"
- click_on "Find"
- end
-
- should "remain on the licence page" do
- assert_equal "/licence-to-kill", current_path
- end
-
- should "see an error message" do
- assert page.has_content? "We couldn't find a council for this postcode."
- end
-
- should "re-populate the invalid input" do
- assert page.has_field? "postcode", with: "XM4 5HQ"
- end
- end
-
- context "when visiting the licence transaction with a postcode where multiple authorities are found" do
- context "when there are 5 or fewer addresses to choose from" do
- setup do
- stub_locations_api_has_location(
- "CH25 9BJ",
- [
- { "address" => "House 1", "local_custodian_code" => "1" },
- { "address" => "House 2", "local_custodian_code" => "2" },
- { "address" => "House 3", "local_custodian_code" => "3" },
- ],
- )
- stub_local_links_manager_has_a_local_authority("Achester", local_custodian_code: 1)
- stub_local_links_manager_has_a_local_authority("Beechester", local_custodian_code: 2)
- stub_local_links_manager_has_a_local_authority("Ceechester", local_custodian_code: 3)
-
- visit "/licence-to-kill"
- fill_in "postcode", with: "CH25 9BJ"
- click_on "Find"
- end
-
- should "prompt you to choose your address" do
- assert page.has_content?("Select an address")
- end
-
- should "display radio buttons" do
- assert page.has_css?(".govuk-radios")
- end
-
- should "contain a list of addresses mapped to authority slugs" do
- assert page.has_content?("House 1")
- assert page.has_content?("House 2")
- assert page.has_content?("House 3")
- end
- end
-
- context "when there are 6 or more addresses to choose from" do
- setup do
- stub_locations_api_has_location(
- "CH25 9BJ",
- [
- { "address" => "House 1", "local_custodian_code" => "1" },
- { "address" => "House 2", "local_custodian_code" => "2" },
- { "address" => "House 3", "local_custodian_code" => "3" },
- { "address" => "House 4", "local_custodian_code" => "4" },
- { "address" => "House 5", "local_custodian_code" => "5" },
- { "address" => "House 6", "local_custodian_code" => "6" },
- { "address" => "House 7", "local_custodian_code" => "7" },
- ],
- )
- stub_local_links_manager_has_a_local_authority("Achester", local_custodian_code: 1)
- stub_local_links_manager_has_a_local_authority("Beechester", local_custodian_code: 2)
- stub_local_links_manager_has_a_local_authority("Ceechester", local_custodian_code: 3)
- stub_local_links_manager_has_a_local_authority("Deechester", local_custodian_code: 4)
- stub_local_links_manager_has_a_local_authority("Eeechester", local_custodian_code: 5)
- stub_local_links_manager_has_a_local_authority("Feechester", local_custodian_code: 6)
- stub_local_links_manager_has_a_local_authority("Geechester", local_custodian_code: 7)
-
- visit "/licence-to-kill"
- fill_in "postcode", with: "CH25 9BJ"
- click_on "Find"
- end
-
- should "prompt you to choose your address" do
- assert page.has_content?("Select an address")
- end
-
- should "display a dropdown select" do
- assert page.has_css?(".govuk-select")
- end
-
- should "contain a list of addresses mapped to authority slugs" do
- assert page.has_content?("House 1")
- assert page.has_content?("House 2")
- assert page.has_content?("House 3")
- assert page.has_content?("House 4")
- assert page.has_content?("House 5")
- assert page.has_content?("House 6")
- assert page.has_content?("House 7")
- end
- end
- end
- end
-
- context "given a non-location specific licence" do
- setup do
- @payload = {
- base_path: "/licence-to-turn-off-a-telescreen",
- document_type: "licence",
- format: "licence",
- schema_name: "licence",
- title: "Licence to turn off a telescreen",
- public_updated_at: "2012-10-02T12:30:33.483Z",
- description: "Descriptive licence text.",
- details: {
- licence_identifier: "1071-5-1",
- licence_overview: "The place where there is no darkness",
- },
- }
-
- stub_content_store_has_item("/licence-to-turn-off-a-telescreen", @payload)
- end
-
- context "with multiple authorities" do
- setup do
- authorities = [
- {
- "authorityName" => "Ministry of Plenty",
- "authoritySlug" => "miniplenty",
- "authorityInteractions" => {
- "apply" => [{
- "url" => "/licence-to-turn-off-a-telescreen/ministry-of-plenty/apply-1",
- "description" => "Apply for your licence to turn off a telescreen",
- "payment" => "none",
- "introduction" => "some intro",
- "usesLicensify" => true,
- }],
- },
- },
- {
- "authorityName" => "Ministry of Love",
- "authoritySlug" => "miniluv",
- "authorityInteractions" => {
- "apply" => [{
- "url" => "/licence-to-turn-off-a-telescreen/ministry-of-love/apply-1",
- "description" => "Apply for your licence to turn off a telescreen",
- "payment" => "none",
- "introduction" => "",
- "usesLicensify" => true,
- }],
- },
- },
- {
- "authorityName" => "Ministry of Truth",
- "authoritySlug" => "minitrue",
- "authorityInteractions" => {
- "apply" => [{
- "url" => "/licence-to-turn-off-a-telescreen/ministry-of-truth/apply-1",
- "description" => "Apply for your licence to turn off a telescreen",
- "payment" => "none",
- "introduction" => "",
- "usesLicensify" => true,
- }],
- },
- },
- {
- "authorityName" => "Ministry of Peace",
- "authoritySlug" => "minipax",
- "authorityInteractions" => {
- "apply" => [{
- "url" => "/licence-to-turn-off-a-telescreen/ministry-of-peace/apply-1",
- "description" => "Apply for your licence to turn off a telescreen",
- "payment" => "none",
- "introduction" => "",
- "usesLicensify" => true,
- }],
- },
- },
- ]
-
- stub_licence_exists(
- "1071-5-1",
- "isLocationSpecific" => false,
- "geographicalAvailability" => %w[England Wales],
- "issuingAuthorities" => authorities,
- )
- end
-
- context "when visiting the license and specifying an authority" do
- setup do
- visit "/licence-to-turn-off-a-telescreen/minitrue"
- end
-
- should "display correct licence" do
- assert page.has_content?("The issuing authority for this licence is Ministry of Truth")
- end
- end
-
- context "when visiting the licence without specifying an authority" do
- setup do
- visit "/licence-to-turn-off-a-telescreen"
- end
-
- should "display the title" do
- assert page.has_content?("Licence to turn off a telescreen")
- end
-
- should "see the available authorities in a list" do
- assert page.has_content?("Ministry of Peace")
- assert page.has_content?("Ministry of Love")
- assert page.has_content?("Ministry of Truth")
- assert page.has_content?("Ministry of Plenty")
- end
-
- context "when selecting an authority" do
- setup do
- choose "Ministry of Love"
- click_on "Get started"
- end
-
- should "redirect to the authority slug" do
- assert_equal "/licence-to-turn-off-a-telescreen/miniluv", current_path
- end
-
- should "display interactions for licence" do
- click_on "How to apply"
- assert current_path == "/licence-to-turn-off-a-telescreen/miniluv/apply"
-
- assert_has_button_as_link(
- "Apply online",
- href: "/licence-to-turn-off-a-telescreen/ministry-of-love/apply-1",
- start: true,
- )
- end
- end
- end
- end
-
- context "with a single authority" do
- setup do
- authorities = [
- {
- "authorityName" => "Ministry of Love",
- "authoritySlug" => "miniluv",
- "authorityInteractions" => {
- "apply" => [
- {
- "url" => "/licence-to-turn-off-a-telescreen/ministry-of-love/apply-1",
- "description" => "Apply for your licence to turn off a telescreen",
- "payment" => "none",
- "introduction" => "",
- "usesLicensify" => true,
- },
- ],
- },
- },
- ]
-
- stub_licence_exists(
- "1071-5-1",
- "isLocationSpecific" => false,
- "geographicalAvailability" => %w[England Wales],
- "issuingAuthorities" => authorities,
- )
- end
-
- context "when visiting the licence" do
- setup do
- visit "/licence-to-turn-off-a-telescreen"
- end
-
- should "display the title" do
- assert page.has_content?("Licence to turn off a telescreen")
- end
-
- should "show licence actions for the single authority" do
- within("#content nav") do
- assert page.has_link? "How to apply", href: "/licence-to-turn-off-a-telescreen/miniluv/apply"
- end
- end
-
- should "display the interactions for licence" do
- click_on "How to apply"
- assert_has_button_as_link(
- "Apply online",
- href: "/licence-to-turn-off-a-telescreen/ministry-of-love/apply-1",
- start: true,
- )
- end
-
- should "show overview section" do
- within("#overview") do
- assert page.has_content?("The place where there is no darkness")
- end
- end
- end
- end
- end
-
- context "given a licence edition with continuation link" do
- setup do
- @payload = {
- base_path: "/artistic-license",
- document_type: "licence",
- format: "licence",
- schema_name: "licence",
- title: "Artistic License",
- public_updated_at: "2012-10-02T12:30:33.483Z",
- description: "Descriptive licence text.",
- details: {
- "will_continue_on" => "another planet",
- "continuation_link" => "http://gov.uk/blah",
- },
- }
-
- stub_content_store_has_item("/artistic-license", @payload)
- end
-
- context "when visiting the licence" do
- setup do
- visit "/artistic-license"
- end
-
- should "not see a location form" do
- assert_not page.has_field?("postcode")
- end
-
- should "see a 'Start now' button" do
- assert page.has_content?("Start now")
- end
- end
-
- context "when visiting the licence with an authority slug" do
- setup do
- visit "/artistic-license/miniluv"
- end
-
- should "redirect to the search page" do
- assert_current_url "/artistic-license"
- end
- end
- end
-
- context "given a licence which does not exist in licensify and uses authority url" do
- setup do
- @payload = {
- base_path: "/some-licence",
- document_type: "licence",
- format: "licence",
- phase: "beta",
- schema_name: "licence",
- title: "Licence of some type",
- public_updated_at: "2012-10-02T12:30:33.483Z",
- description: "Descriptive licence text.",
- details: {
- lgsl_code: 461,
- lgil_code: 8,
- licence_identifier: "1071-5-1",
- licence_overview: "This is a licence.\n",
- },
- }
-
- stub_content_store_has_item("/a-licence", @payload)
-
- configure_locations_api_and_local_authority("SW1A 1AA", %w[a-council], 5990)
- stub_local_links_manager_does_not_have_an_authority("not-a-valid-council-name")
-
- authorities = [
- {
- "authorityName" => "A Council",
- "authoritySlug" => "a-council",
- "authorityContact" => {
- "website" => "",
- "email" => "",
- "phone" => "020 7641 6000",
- "address" => "P.O. Box 123\nSome Town\nXY1 1AB",
- },
- "authorityInteractions" => {
- "apply" => [
- {
- "url" => "http://some-council-website",
- "description" => "Apply for your licence",
- "payment" => "none",
- "introduction" => "This licence is issued online",
- "usesLicensify" => false,
- "usesAuthorityUrl" => true,
- },
- ],
- },
- },
- ]
- stub_licence_exists(
- "1071-5-1",
- "isLocationSpecific" => true,
- "isOfferedByCounty" => false,
- "geographicalAvailability" => %w[England Wales],
- "issuingAuthorities" => authorities,
- )
- stub_licence_exists(
- "1071-5-1/00BK",
- "isLocationSpecific" => true,
- "isOfferedByCounty" => false,
- "geographicalAvailability" => %w[England Wales],
- "issuingAuthorities" => authorities,
- )
- end
-
- should "show message to contact local council through their website" do
- visit "/a-licence/a-council/apply"
-
- assert page.has_content? "To obtain this licence, you need to contact the authority directly"
- assert page.has_content? "To continue, go to"
- assert page.has_link? "A Council", href: "http://some-council-website"
- end
- end
-
- context "given a licence which does not exist in licensify" do
- setup do
- @payload = {
- base_path: "/licence-to-kill",
- document_type: "licence",
- format: "licence",
- schema_name: "licence",
- title: "Licence to kill",
- public_updated_at: "2012-10-02T12:30:33.483Z",
- description: "Descriptive licence text.",
- details: {
- licence_identifier: "1071-5-1",
- },
- }
-
- stub_content_store_has_item("/licence-to-kill", @payload)
-
- stub_licence_does_not_exist("1071-5-1")
- end
-
- should "show message to contact local council" do
- visit "/licence-to-kill"
-
- assert page.has_content?("You cannot apply for this licence online")
- assert page.has_content?("Contact your local council.")
- end
- end
-
- context "given that licensify times out" do
- setup do
- @payload = {
- base_path: "/licence-to-kill",
- document_type: "licence",
- format: "licence",
- schema_name: "licence",
- title: "Licence to kill",
- public_updated_at: "2012-10-02T12:30:33.483Z",
- description: "Descriptive licence text.",
- details: {
- licence_identifier: "1071-5-1",
- },
- }
-
- stub_content_store_has_item("/licence-to-kill", @payload)
- stub_licence_times_out("1071-5-1")
- end
-
- should "show an error" do
- visit "/licence-to-kill"
- assert_equal page.status_code, 503
- end
- end
-
- context "given that licensify errors" do
- setup do
- @payload = {
- base_path: "/licence-to-kill",
- document_type: "licence",
- format: "licence",
- schema_name: "licence",
- title: "Licence to kill",
- public_updated_at: "2012-10-02T12:30:33.483Z",
- description: "Descriptive licence text.",
- details: {
- licence_identifier: "1071-5-1",
- },
- }
-
- stub_content_store_has_item("/licence-to-kill", @payload)
- stub_licence_returns_error("1071-5-1")
- end
-
- should "show an error" do
- visit "/licence-to-kill"
- assert_equal page.status_code, 503
- end
- end
-
- context "given the usesLicensify parameter" do
- setup do
- @payload = {
- base_path: "/licence-to-kill",
- document_type: "licence",
- format: "licence",
- schema_name: "licence",
- title: "Licence to kill",
- public_updated_at: "2012-10-02T12:30:33.483Z",
- description: "Descriptive licence text.",
- details: {
- licence_identifier: "1071-5-1",
- },
- }
-
- stub_content_store_has_item("/licence-to-kill", @payload)
- end
-
- context "when visiting an authority with no actions" do
- setup do
- authorities = [
- {
- "authorityName" => "Ministry of Love",
- "authoritySlug" => "miniluv",
- "authorityInteractions" => {},
- },
- ]
-
- stub_licence_exists(
- "1071-5-1",
- "isLocationSpecific" => false,
- "geographicalAvailability" => %w[England Wales],
- "issuingAuthorities" => authorities,
- )
-
- visit "/licence-to-kill"
- end
-
- should "display the title" do
- assert page.has_content?("Licence to kill")
- end
-
- should "not display authority" do
- assert_not page.has_content? "Ministry of Love"
- assert_not page.has_button? "Get started"
- end
-
- should "display the licence unavailable message" do
- assert page.has_content?("You cannot apply for this licence online")
- assert page.has_content?("Contact your local council.")
- end
- end
-
- context "when there's at least one action with usesLicensify set to true" do
- setup do
- authorities = [
- {
- "authorityName" => "Ministry of Love",
- "authoritySlug" => "miniluv",
- "authorityInteractions" => {
- "apply" => [
- {
- "url" => "/licence-to-kill/ministry-of-love/apply-1",
- "description" => "Apply for your licence",
- "payment" => "none",
- "introduction" => "",
- "usesLicensify" => true,
- },
- ],
- "renew" => [
- {
- "url" => "/licence-to-kill/ministry-of-love/renew-1",
- "description" => "Apply for your licence",
- "payment" => "none",
- "introduction" => "",
- "usesLicensify" => false,
- },
- ],
- },
- },
- ]
-
- stub_licence_exists(
- "1071-5-1",
- "isLocationSpecific" => false,
- "geographicalAvailability" => %w[England Wales],
- "issuingAuthorities" => authorities,
- )
-
- visit "/licence-to-kill"
- end
-
- should "display the title" do
- assert page.has_content?("Licence to kill")
- end
-
- should "display the authority" do
- assert page.has_content?("Ministry of Love")
- end
-
- should "show licence actions that have usesLicensify set to true" do
- within("#content nav") do
- assert page.has_link? "How to apply", href: "/licence-to-kill/miniluv/apply"
- end
- end
-
- should "show licence actions that have usesLicensify set to false" do
- within("#content nav") do
- assert page.has_link? "How to renew", href: "/licence-to-kill/miniluv/renew"
- end
- end
-
- should "display the interactions for the licence if usesLicensify is set to true" do
- click_link "How to apply"
-
- assert current_path == "/licence-to-kill/miniluv/apply"
-
- assert_has_button_as_link(
- "Apply online",
- href: "/licence-to-kill/ministry-of-love/apply-1",
- start: true,
- )
- assert_not page.has_content?("You cannot apply for this licence online")
- assert_not page.has_content?("Contact your local council.")
- end
-
- should "not display the interactions for the licence if usesLicensify is set to false" do
- click_link "How to renew"
-
- assert current_path == "/licence-to-kill/miniluv/renew"
-
- refute_has_button_component(
- "Apply online",
- href: "/licence-to-kill/ministry-of-love/renew-1",
- start: true,
- )
- assert page.has_content?("You cannot apply for this licence online")
- assert page.has_content?("Contact your local council.")
- end
- end
-
- context "when all actions have usesLicensify set to false" do
- setup do
- authorities = [
- {
- "authorityName" => "Ministry of Love",
- "authoritySlug" => "miniluv",
- "authorityInteractions" => {
- "apply" => [
- {
- "url" => "/licence-to-kill/ministry-of-love/apply-1",
- "description" => "Apply for your licence",
- "payment" => "none",
- "introduction" => "",
- "usesLicensify" => false,
- },
- ],
- "renew" => [
- {
- "url" => "/licence-to-kill/ministry-of-love/renew-1",
- "description" => "Apply for your licence",
- "payment" => "none",
- "introduction" => "",
- "usesLicensify" => false,
- },
- ],
- },
- },
- ]
-
- stub_licence_exists(
- "1071-5-1",
- "isLocationSpecific" => false,
- "geographicalAvailability" => %w[England Wales],
- "issuingAuthorities" => authorities,
- )
-
- visit "/licence-to-kill"
- end
-
- should "display the title" do
- assert page.has_content?("Licence to kill")
- end
-
- should "display authority" do
- assert page.has_content? "Ministry of Love"
- end
-
- should "display the actions" do
- assert page.has_content? "Overview"
- assert page.has_link? "How to apply", href: "/licence-to-kill/miniluv/apply"
- assert page.has_link? "How to renew", href: "/licence-to-kill/miniluv/renew"
- end
-
- should "not display the licence unavailable message on the main licence page" do
- assert_not page.has_content?("You cannot apply for this licence online")
- assert_not page.has_content?("Contact your local council.")
- end
-
- should "display the licence unavailable message after you click on the first action" do
- click_on "How to apply"
-
- assert current_path == "/licence-to-kill/miniluv/apply"
-
- refute_has_button_component(
- "Apply online",
- href: "/licence-to-kill/ministry-of-love/apply-1",
- start: true,
- )
-
- assert page.has_content?("You cannot apply for this licence online")
- assert page.has_content?("Contact your local council.")
- end
-
- should "display the licence unavailable message after you click on the second action" do
- click_on "How to renew"
-
- assert current_path == "/licence-to-kill/miniluv/renew"
-
- refute_has_button_component(
- "Apply online",
- href: "/licence-to-kill/ministry-of-love/renew-1",
- start: true,
- )
-
- assert page.has_content?("You cannot apply for this licence online")
- assert page.has_content?("Contact your local council.")
- end
- end
-
- context "when usesLicensify is missing for one action" do
- setup do
- authorities = [
- {
- "authorityName" => "Ministry of Love",
- "authoritySlug" => "miniluv",
- "authorityInteractions" => {
- "apply" => [
- {
- "url" => "/licence-to-kill/ministry-of-love/apply-1",
- "description" => "Apply for your licence",
- "payment" => "none",
- "introduction" => "",
- },
- ],
- "renew" => [
- {
- "url" => "/licence-to-kill/ministry-of-love/renew-1",
- "description" => "Apply for your licence",
- "payment" => "none",
- "introduction" => "",
- "usesLicensify" => true,
- },
- ],
- },
- },
- ]
-
- stub_licence_exists(
- "1071-5-1",
- "isLocationSpecific" => false,
- "geographicalAvailability" => %w[England Wales],
- "issuingAuthorities" => authorities,
- )
-
- visit "/licence-to-kill"
- end
-
- should "display the title and authority" do
- assert page.has_content? "Licence to kill"
- assert page.has_content? "Ministry of Love"
- end
-
- should "show licence actions that don't have the usesLicensify param" do
- within("#content nav") do
- assert page.has_link? "How to apply", href: "/licence-to-kill/miniluv/apply"
- end
- end
-
- should "show licence actions that have usesLicensify set to true" do
- within("#content nav") do
- assert page.has_link? "How to renew", href: "/licence-to-kill/miniluv/renew"
- end
- end
-
- should "not display interactions for licence with missing usesLicensify" do
- click_on "How to apply"
-
- assert current_path == "/licence-to-kill/miniluv/apply"
-
- refute_has_button_component(
- "Apply online",
- href: "/licence-to-kill/ministry-of-love/apply-1",
- start: true,
- )
-
- assert page.has_content?("You cannot apply for this licence online")
- assert page.has_content?("Contact your local council.")
- end
-
- should "display interactions for licence with usesLicensify set to true" do
- click_on "How to renew"
-
- assert current_path == "/licence-to-kill/miniluv/renew"
-
- assert_has_button_as_link(
- "Apply online",
- href: "/licence-to-kill/ministry-of-love/renew-1",
- start: true,
- )
-
- assert_not page.has_content?("You cannot apply for this licence online")
- assert_not page.has_content?("Contact your local council.")
- end
- end
-
- context "when usesLicensify is missing for all actions" do
- setup do
- authorities = [
- {
- "authorityName" => "Ministry of Love",
- "authoritySlug" => "miniluv",
- "authorityInteractions" => {
- "apply" => [
- {
- "url" => "/licence-to-kill/ministry-of-love/apply-1",
- "description" => "Apply for your licence",
- "payment" => "none",
- "introduction" => "",
- },
- ],
- "renew" => [
- {
- "url" => "/licence-to-kill/ministry-of-love/renew-1",
- "description" => "Apply for your licence",
- "payment" => "none",
- "introduction" => "",
- },
- ],
- },
- },
- ]
-
- stub_licence_exists(
- "1071-5-1",
- "isLocationSpecific" => false,
- "geographicalAvailability" => %w[England Wales],
- "issuingAuthorities" => authorities,
- )
-
- visit "/licence-to-kill"
- end
-
- should "display the title" do
- assert page.has_content?("Licence to kill")
- end
-
- should "display authority" do
- assert page.has_content? "Ministry of Love"
- end
-
- should "display the actions" do
- assert page.has_content? "Overview"
- assert page.has_link? "How to apply", href: "/licence-to-kill/miniluv/apply"
- assert page.has_link? "How to renew", href: "/licence-to-kill/miniluv/renew"
- end
-
- should "not display the licence unavailable message on the main licence page" do
- assert_not page.has_content?("You cannot apply for this licence online")
- assert_not page.has_content?("Contact your local council.")
- end
-
- should "display the licence unavailable message after you click on an action" do
- click_on "How to apply"
-
- assert current_path == "/licence-to-kill/miniluv/apply"
-
- refute_has_button_component(
- "Apply online",
- href: "/licence-to-kill/ministry-of-love/apply-1",
- start: true,
- )
-
- assert page.has_content?("You cannot apply for this licence online")
- assert page.has_content?("Contact your local council.")
- end
- end
-
- context "when an action has multiple links, some with usesLicensify set to true" do
- setup do
- authorities = [
- {
- "authorityName" => "Ministry of Love",
- "authoritySlug" => "miniluv",
- "authorityInteractions" => {
- "apply" => [
- {
- "url" => "/licence-to-kill/ministry-of-love/apply-1",
- "description" => "Apply for your licence",
- "payment" => "none",
- "introduction" => "",
- "usesLicensify" => true,
- },
- {
- "url" => "/licence-to-kill/ministry-of-love/apply-2",
- "description" => "Apply for your licence",
- "payment" => "none",
- "introduction" => "",
- "usesLicensify" => false,
- },
- {
- "url" => "/licence-to-kill/ministry-of-love/apply-3",
- "description" => "Apply for your licence",
- "payment" => "none",
- "introduction" => "",
- "usesLicensify" => true,
- },
- ],
- "renew" => [
- {
- "url" => "/licence-to-kill/ministry-of-love/renew-1",
- "description" => "Apply for your licence",
- "payment" => "none",
- "introduction" => "",
- "usesLicensify" => false,
- },
- {
- "url" => "/licence-to-kill/ministry-of-love/renew-2",
- "description" => "Apply for your licence",
- "payment" => "none",
- "introduction" => "",
- },
- ],
- },
- },
- ]
-
- stub_licence_exists(
- "1071-5-1",
- "isLocationSpecific" => false,
- "geographicalAvailability" => %w[England Wales],
- "issuingAuthorities" => authorities,
- )
-
- visit "/licence-to-kill"
- end
-
- should "display the title" do
- assert page.has_content?("Licence to kill")
- end
-
- should "display the authority" do
- assert page.has_content?("Ministry of Love")
- end
-
- should "show licence actions that have usesLicensify set to true" do
- within("#content nav") do
- assert page.has_link? "How to apply", href: "/licence-to-kill/miniluv/apply"
- end
- end
-
- should "show licence actions that have usesLicensify set to false" do
- within("#content nav") do
- assert page.has_link? "How to renew", href: "/licence-to-kill/miniluv/renew"
- end
- end
-
- should "display the interactions for the licence if usesLicensify is set to true for a link" do
- click_link "How to apply"
-
- assert current_path == "/licence-to-kill/miniluv/apply"
-
- assert_has_button_as_link(
- "Apply online",
- href: "/licence-to-kill/ministry-of-love/apply-1",
- start: true,
- )
- assert_has_button_as_link(
- "Apply online",
- start: true,
- href: "/licence-to-kill/ministry-of-love/apply-3",
- )
-
- refute_has_button_component(
- "Apply online",
- href: "/licence-to-kill/ministry-of-love/apply-2",
- start: true,
- )
- assert page.has_content?("You cannot apply for this licence online")
- assert page.has_content?("Contact your local council.")
- end
-
- should "not display the interactions for the licence if usesLicensify is set to false or is missing for a link" do
- click_link "How to renew"
-
- assert current_path == "/licence-to-kill/miniluv/renew"
-
- refute_has_button_component(
- "Apply online",
- href: "/licence-to-kill/ministry-of-love/renew-1",
- start: true,
- )
- refute_has_button_component(
- "Apply online",
- href: "/licence-to-kill/ministry-of-love/renew-2",
- start: true,
- )
- assert page.has_content?("You cannot apply for this licence online")
- assert page.has_content?("Contact your local council.")
- end
- end
- end
-end
diff --git a/test/unit/presenters/licence_presenter_test.rb b/test/unit/presenters/licence_presenter_test.rb
deleted file mode 100644
index 0d2e1b79cd..0000000000
--- a/test/unit/presenters/licence_presenter_test.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-require "test_helper"
-
-class LicencePresenterTest < ActiveSupport::TestCase
- def subject(content_item)
- LicencePresenter.new(content_item.deep_stringify_keys!)
- end
-
- test "#introduction" do
- assert_equal "https://continue-here.gov.uk", subject(details: { continuation_link: "https://continue-here.gov.uk" }).continuation_link
- end
-
- test "#licence_identifier" do
- assert_equal "123", subject(details: { licence_identifier: "123" }).licence_identifier
- end
-
- test "#licence_overview" do
- assert_equal "Overview of the licence", subject(details: { licence_overview: "Overview of the licence" }).licence_overview
- end
-
- test "#licence_short_description" do
- assert_equal "Short description", subject(details: { licence_short_description: "Short description" }).licence_short_description
- end
-
- test "#will_continue_on" do
- assert_equal "Westminster Council", subject(details: { will_continue_on: "Westminster Council" }).will_continue_on
- end
-end