Browse Source

CLDC-1726 Update scheme and location display pages (#1190)

* feat: update scheme and log displays

* test: update tests

* test: update tests
pull/1185/head
natdeanlewissoftwire 2 years ago committed by GitHub
parent
commit
ecdc4d99c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/helpers/tab_nav_helper.rb
  2. 4
      app/views/locations/index.html.erb
  3. 10
      spec/features/schemes_spec.rb
  4. 4
      spec/helpers/tab_nav_helper_spec.rb

4
app/helpers/tab_nav_helper.rb

@ -8,13 +8,13 @@ module TabNavHelper
def location_cell_postcode(location, link) def location_cell_postcode(location, link)
link_text = location.postcode || "Add postcode" link_text = location.postcode || "Add postcode"
[govuk_link_to(link_text, link, method: :patch), "<span class=\"govuk-visually-hidden\">Location </span><span class=\"govuk-!-font-weight-regular app-!-colour-muted\">#{location.name}</span>"].join("\n") [govuk_link_to(link_text, link, method: :patch), "<span class=\"govuk-visually-hidden\">Location</span>"].join("\n")
end end
def scheme_cell(scheme) def scheme_cell(scheme)
link_text = scheme.service_name link_text = scheme.service_name
link = scheme.confirmed? ? scheme : scheme_check_answers_path(scheme) link = scheme.confirmed? ? scheme : scheme_check_answers_path(scheme)
[govuk_link_to(link_text, link), "<span class=\"govuk-visually-hidden\">Scheme </span><span class=\"govuk-!-font-weight-regular app-!-colour-muted\">#{scheme.primary_client_group}</span>"].join("\n") [govuk_link_to(link_text, link), "<span class=\"govuk-visually-hidden\">Scheme</span>"].join("\n")
end end
def org_cell(user) def org_cell(user)

4
app/views/locations/index.html.erb

@ -39,6 +39,9 @@
<% row.cell(header: true, text: "Postcode", html_attributes: { <% row.cell(header: true, text: "Postcode", html_attributes: {
scope: "col", scope: "col",
}) %> }) %>
<% row.cell(header: true, text: "Name", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Location code", html_attributes: { <% row.cell(header: true, text: "Location code", html_attributes: {
scope: "col", scope: "col",
}) %> }) %>
@ -55,6 +58,7 @@
else else
location.postcode.present? ? scheme_location_check_answers_path(@scheme, location, route: "locations") : scheme_location_postcode_path(@scheme, location) location.postcode.present? ? scheme_location_check_answers_path(@scheme, location, route: "locations") : scheme_location_postcode_path(@scheme, location)
end), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %> end), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %>
<% row.cell(text: location.name) %>
<% row.cell(text: location.id) %> <% row.cell(text: location.id) %>
<% row.cell(text: status_tag(location.status)) %> <% row.cell(text: status_tag(location.status)) %>
<% end %> <% end %>

10
spec/features/schemes_spec.rb

@ -101,9 +101,9 @@ RSpec.describe "Schemes scheme Features" do
it "shows a list of schemes" do it "shows a list of schemes" do
schemes.each do |scheme| schemes.each do |scheme|
expect(page).to have_content(scheme.id)
expect(page).to have_link(scheme.service_name) expect(page).to have_link(scheme.service_name)
expect(page).to have_content(scheme.primary_client_group) expect(page).to have_content(scheme.id_to_display)
expect(page).to have_content(scheme.locations&.count)
end end
end end
@ -175,7 +175,8 @@ RSpec.describe "Schemes scheme Features" do
click_on("Back") click_on("Back")
schemes.each do |scheme| schemes.each do |scheme|
expect(page).to have_link(scheme.service_name) expect(page).to have_link(scheme.service_name)
expect(page).to have_content(scheme.primary_client_group) expect(page).to have_content(scheme.id_to_display)
expect(page).to have_content(scheme.locations&.count)
end end
end end
end end
@ -671,7 +672,8 @@ RSpec.describe "Schemes scheme Features" do
it "shows list of links to schemes" do it "shows list of links to schemes" do
schemes.each do |scheme| schemes.each do |scheme|
expect(page).to have_link(scheme.service_name) expect(page).to have_link(scheme.service_name)
expect(page).to have_content(scheme.primary_client_group) expect(page).to have_content(scheme.id_to_display)
expect(page).to have_content(scheme.locations&.count)
end end
end end

4
spec/helpers/tab_nav_helper_spec.rb

@ -23,14 +23,14 @@ RSpec.describe TabNavHelper do
describe "#location_cell" do describe "#location_cell" do
it "returns the location link to the postcode with optional name" do it "returns the location link to the postcode with optional name" do
link = "/schemes/#{location.scheme.id}/locations/#{location.id}/edit" link = "/schemes/#{location.scheme.id}/locations/#{location.id}/edit"
expected_html = "<a class=\"govuk-link\" rel=\"nofollow\" data-method=\"patch\" href=\"/schemes/#{scheme.id}/locations/#{location.id}/edit\">#{location.postcode}</a>\n<span class=\"govuk-visually-hidden\">Location </span><span class=\"govuk-!-font-weight-regular app-!-colour-muted\">#{location.name}</span>" expected_html = "<a class=\"govuk-link\" rel=\"nofollow\" data-method=\"patch\" href=\"/schemes/#{scheme.id}/locations/#{location.id}/edit\">#{location.postcode}</a>\n<span class=\"govuk-visually-hidden\">Location</span>"
expect(location_cell_postcode(location, link)).to match(expected_html) expect(location_cell_postcode(location, link)).to match(expected_html)
end end
end end
describe "#scheme_cell" do describe "#scheme_cell" do
it "returns the scheme link service name and primary user group separated by a newline character" do it "returns the scheme link service name and primary user group separated by a newline character" do
expected_html = "<a class=\"govuk-link\" href=\"/schemes/#{scheme.id}\">#{scheme.service_name}</a>\n<span class=\"govuk-visually-hidden\">Scheme </span><span class=\"govuk-!-font-weight-regular app-!-colour-muted\">#{scheme.primary_client_group}</span>" expected_html = "<a class=\"govuk-link\" href=\"/schemes/#{scheme.id}\">#{scheme.service_name}</a>\n<span class=\"govuk-visually-hidden\">Scheme</span>"
expect(scheme_cell(scheme)).to match(expected_html) expect(scheme_cell(scheme)).to match(expected_html)
end end
end end

Loading…
Cancel
Save