Browse Source

Add a failing log filter test for specific org

pull/557/head
Kat 3 years ago
parent
commit
013e1bbe92
  1. 2
      app/views/case_logs/_log_filters.erb
  2. 33
      spec/features/organisation_spec.rb

2
app/views/case_logs/_log_filters.erb

@ -4,7 +4,7 @@
<h2 class="govuk-heading-m">Filters</h2> <h2 class="govuk-heading-m">Filters</h2>
</div> </div>
<div class="app-filter__content"> <div class="app-filter__content">
<%= form_with url: "/logs", html: { method: :get } do |f| %> <%= form_with html: { method: :get } do |f| %>
<% years = {"2021": "2021/22", "2022": "2022/23"} %> <% years = {"2021": "2021/22", "2022": "2022/23"} %>
<% all_or_yours = {"all": { label: "All" }, "yours": { label: "Yours" } } %> <% all_or_yours = {"all": { label: "All" }, "yours": { label: "Yours" } } %>
<%= render partial: "filters/checkbox_filter", locals: { f: f, options: years, label: "Collection year", category: "years" } %> <%= render partial: "filters/checkbox_filter", locals: { f: f, options: years, label: "Collection year", category: "years" } %>

33
spec/features/organisation_spec.rb

@ -15,7 +15,7 @@ RSpec.describe "User Features" do
allow(devise_notify_mailer).to receive(:notify_client).and_return(notify_client) allow(devise_notify_mailer).to receive(:notify_client).and_return(notify_client)
allow(Devise).to receive(:friendly_token).and_return(confirmation_token) allow(Devise).to receive(:friendly_token).and_return(confirmation_token)
allow(notify_client).to receive(:send_email).and_return(true) allow(notify_client).to receive(:send_email).and_return(true)
sign_in user # sign_in user
end end
context "when user is a data coordinator" do context "when user is a data coordinator" do
@ -80,4 +80,35 @@ RSpec.describe "User Features" do
end end
end end
end end
context "when user is support user" do
context "when viewing logs for specific organisation" do
let(:user) { FactoryBot.create(:user, :support) }
let(:number_of_case_logs) { 4 }
let(:first_log) {organisation.case_logs.first}
let(:otp) { "999111" }
before do
FactoryBot.create_list(:case_log, number_of_case_logs, owning_organisation_id: organisation.id, managing_organisation_id: organisation.id)
first_log.update!(startdate: Time.utc(2022, 6, 2, 10, 36, 49))
allow(SecureRandom).to receive(:random_number).and_return(otp)
sign_in user
fill_in("code", with: otp)
click_button("Submit")
visit("/organisations/#{org_id}/logs")
end
it "can filter case logs" do
expect(page).to have_content("#{number_of_case_logs} total logs")
organisation.case_logs.map(&:id).each do |case_log_id|
expect(page).to have_link case_log_id.to_s, href: "/logs/#{case_log_id}"
end
check("years-2022-field")
click_button("Apply filters")
expect(page).to have_current_path("/organisations/#{org_id}/logs?years[]=&years[]=2022&status[]=&user=all&organisation_select=all&organisation=")
expect(page).not_to have_link first_log.id.to_s, href: "/logs/#{first_log.id}"
end
end
end
end end

Loading…
Cancel
Save