Skip to content

Commit

Permalink
Add 'No teachers found' content and link back to search page
Browse files Browse the repository at this point in the history
  • Loading branch information
AbigailMcP authored and AbigailMcP committed Sep 12, 2023
1 parent f438556 commit bbb3074
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 26 deletions.
58 changes: 32 additions & 26 deletions app/views/check_records/search/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,38 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds-from-desktop">
<h1 class="govuk-heading-l">Search results (<%= @total %>)</h1>
<% if @total.zero? %>
<p class="govuk-body">
No teachers found.
<%= govuk_link_to("Try another search", check_records_search_path) %>.
</p>
<% else %>
<div class="search-results">
<% @teachers.each do |teacher| %>
<div class="search-results__item">
<h2 class="govuk-heading-s">
<%= link_to teacher.name, check_records_teacher_path(teacher.trn), class: "govuk-link--no-visited-state" %>
</h2>
<strong class="govuk-tag govuk-tag--<%= teacher.sanctions.any? ? "red" : "green" %>"%>
<%= teacher.sanctions.any? ? "Restrictions" : "No restrictions" %>
</strong>

<div class="search-results">
<% @teachers.each do |teacher| %>
<div class="search-results__item">
<h2 class="govuk-heading-s">
<%= link_to teacher.name, check_records_teacher_path(teacher.trn), class: "govuk-link--no-visited-state" %>
</h2>
<strong class="govuk-tag govuk-tag--<%= teacher.sanctions.any? ? "red" : "green" %>"%>
<%= teacher.sanctions.any? ? "Restrictions" : "No restrictions" %>
</strong>

<%
rows = [
{
key: { text: "TRN" },
value: { text: teacher.trn }
},
{
key: { text: "Date of birth" },
value: { text: Date.parse(teacher.date_of_birth).to_fs(:long_uk) }
}
]
%>
<%= render GovukComponent::SummaryListComponent.new(rows:, borders: false, classes: ['app-summary-list--compact']) %>
</div>
<% end %>
</div>
<%
rows = [
{
key: { text: "TRN" },
value: { text: teacher.trn }
},
{
key: { text: "Date of birth" },
value: { text: Date.parse(teacher.date_of_birth).to_fs(:long_uk) }
}
]
%>
<%= render GovukComponent::SummaryListComponent.new(rows:, borders: false, classes: ['app-summary-list--compact']) %>
</div>
<% end %>
</div>
<% end %>
</div>
</div>
2 changes: 2 additions & 0 deletions spec/support/fake_qualifications_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class FakeQualificationsApi < Sinatra::Base

case bearer_token
when "token"
return { total: 0, results: [] }.to_json if params["lastName"] == "No match"

{
total: 1,
results: [teacher_data(sanctions: params["lastName"] == "Restricted")]
Expand Down
29 changes: 29 additions & 0 deletions spec/system/check_records/user_searches_with_no_matches_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require "rails_helper"

RSpec.describe "No matches", host: :check_records, type: :system do
include ActivateFeaturesSteps
include CheckRecords::AuthenticationSteps

scenario "User searches with a last name and date of birth and finds no matches",
test: %i[with_stubbed_auth with_fake_quals_api] do
given_the_service_is_open
when_i_sign_in_via_dsi
and_search_returns_no_records
then_i_see_no_records
end

private

def and_search_returns_no_records
fill_in "Last name", with: "No match"
fill_in "Day", with: "1"
fill_in "Month", with: "1"
fill_in "Year", with: "1990"
click_button "Find record"
end

def then_i_see_no_records
expect(page).to have_content("No teachers found")
expect(page).to have_link("Try another search")
end
end

0 comments on commit bbb3074

Please sign in to comment.