Browse Source

set up failing test for organisation logs page

pull/557/head
Dushan Despotovic 3 years ago committed by Kat
parent
commit
6b375c2048
  1. 3
      app/controllers/organisations_controller.rb
  2. 2
      app/views/organisations/logs.erb
  3. 17
      spec/features/user_spec.rb
  4. 2
      spec/rails_helper.rb

3
app/controllers/organisations_controller.rb

@ -43,7 +43,8 @@ class OrganisationsController < ApplicationController
end
def logs
unless current_user.support?
if current_user.support?
@pagy, @case_logs = pagy(CaseLog.all.where(owning_organisation_id: @organisation.id))
redirect_to "/logs"
end
end

2
app/views/organisations/logs.erb

@ -1 +1 @@
wubwub
<%= render partial: "case_logs/log_list", locals: { case_logs: @case_logs, title: "Logs", pagy: @pagy } %>

17
spec/features/user_spec.rb

@ -551,6 +551,12 @@ RSpec.describe "User Features" do
end
context "when the user is logged in as a support user" do
let!(:support_user) { FactoryBot.create(:user, :support) }
let!(:test_org_1) { FactoryBot.create(:organisation, name: "Test1") }
let!(:test_org_2) { FactoryBot.create(:organisation, name: "Test2") }
let!(:test_org_3) { FactoryBot.create(:organisation, name: "Test3") }
let!(:test_org_4) { FactoryBot.create(:organisation, name: "Test4") }
let!(:test_org_5) { FactoryBot.create(:organisation, name: "Test5") }
let!(:case_log) { FactoryBot.create(:case_log, owning_organisation_id: test_org_3.id, managing_organisation_id: test_org_3.id) }
before do
FactoryBot.create_list(:organisation, 50)
@ -573,6 +579,17 @@ RSpec.describe "User Features" do
expect(page).to have_css("#all-organisations-table")
expect(page).to have_css(".app-pagination__link")
end
context "when the support user is on the organisations list page" do
it "they can click on an organisation to see their logs page", js: true do
visit("/organisations")
click_link("Test3")
expect(page).to have_selector("a", text: "#{case_log.id}")
visit("/organisations")
click_link("Test5")
expect(page).not_to have_selector("a", text: "#{case_log.id}")
end
end
end
end
end

2
spec/rails_helper.rb

@ -11,7 +11,7 @@ require "view_component/test_helpers"
Capybara.register_driver :headless do |app|
options = Selenium::WebDriver::Firefox::Options.new
options.add_argument("--headless")
# options.add_argument("--headless")
Capybara::Selenium::Driver.new(app, browser: :firefox, capabilities: options)
end

Loading…
Cancel
Save