Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquinco committed Jan 15, 2025
1 parent 0eb5119 commit bb4fb09
Showing 1 changed file with 51 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

RSpec.describe "Sanger Product" do
let(:facility) { create(:setup_facility, sanger_sequencing_enabled: true) }
let(:service) { create(:setup_service, sanger_sequencing_enabled: true) }
let(:service) { create(:setup_service, facility:, sanger_sequencing_enabled: true) }
let(:admin) { create(:user, :facility_administrator, facility:) }
let(:user) { create(:user) }

Expand All @@ -29,7 +29,7 @@
end
end

context "when logged in as admin" do
context "when logged in as facility admin" do
before { login_as admin }

it "requires the facility to be sanger enabled" do
Expand All @@ -40,13 +40,59 @@
expect(page).to have_content("Not Found")
end

it "shows the tab if service is sanger enabled" do
service.update(sanger_sequencing_enabled: true)
it "does not show the tab if service is sanger disabled" do
service.update(sanger_sequencing_enabled: false)

visit facility_service_sanger_sequencing_sanger_product_path(facility, service)

within(".nav-tabs") do
expect(page).to_not have_content("Sanger")
end
end

it "shows the tab if service is sanger enabled" do
visit facility_service_sanger_sequencing_sanger_product_path(facility, service)

expect(page).to have_content("Sanger")
within(".nav-tabs") do
expect(page).to have_content("Sanger")
end
end
end
end

describe "sanger product show" do
before { login_as admin }

it "can navigate by clicking the tab" do
visit manage_facility_service_path(facility, service)

within(".nav-tabs") do
click_link("Sanger")
end

expect(page).to have_content("Sanger Configuration")
end

it "shows sanger product information" do
visit facility_service_sanger_sequencing_sanger_product_path(facility, service)

expect(page).to have_content("Sanger Configuration")
expect(page).to have_content("Needs a Primer")
expect(page).to have_content("Plated Service Type")
expect(page).to have_link("Edit")
end

it "allows to edit sanger product" do
visit facility_service_sanger_sequencing_sanger_product_path(facility, service)

click_link("Edit")

check("sanger_sequencing_sanger_product[needs_primer]")
select("Fragment Analysis", from: "sanger_sequencing_sanger_product[group]")

click_button("Save")

expect(page).to have_content("Sanger Configuration updated successfully")
end
end
end

0 comments on commit bb4fb09

Please sign in to comment.