Skip to content

Commit

Permalink
Add rspec-retry to feature specs
Browse files Browse the repository at this point in the history
  • Loading branch information
ysbaddaden committed Dec 8, 2023
1 parent bca4710 commit eff732a
Show file tree
Hide file tree
Showing 16 changed files with 95 additions and 76 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ group :test do
gem 'rspec', '~> 3.3'
gem 'rspec-collection_matchers', '~> 1.1'
gem 'rspec-rails', '~> 3.3'
gem 'rspec-retry'

gem 'database_cleaner', '~> 1.99'
gem 'machinist', '~> 2.0' # NOTE: eventually replace with FactoryBot
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,8 @@ GEM
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-support (~> 3.9.0)
rspec-retry (0.6.2)
rspec-core (> 3.3)
rspec-support (3.9.4)
rubocop (1.12.1)
parallel (~> 1.10)
Expand Down Expand Up @@ -682,6 +684,7 @@ DEPENDENCIES
rspec (~> 3.3)
rspec-collection_matchers (~> 1.1)
rspec-rails (~> 3.3)
rspec-retry
rubocop-rails
rubocop-rspec
rubyzip (>= 1.0.0)
Expand Down
36 changes: 18 additions & 18 deletions spec/features/boxes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

describe "add_batches" do

it "adds and removes batches and concentrations" do
it "adds and removes batches and concentrations", js: true do
goto_page NewBoxPage do |form|
form.fill(option: "add_batches")

Expand Down Expand Up @@ -76,7 +76,7 @@
end

describe "LOD purpose" do
it "creates the box and its samples" do
it "creates the box and its samples", js: true do
goto_page NewBoxPage do |form|
form.fill(purpose: "LOD", media: media, option: "add_batches")
form.add_batch(virus_1, concentrations: [[2, 10], [3, 100], [4, 1000]])
Expand All @@ -94,7 +94,7 @@
end
end

it "validates that we selected at least one batch" do
it "validates that we selected at least one batch", js: true do
goto_page NewBoxPage do |form|
form.fill(purpose: "LOD", media: media, option: "add_batches")
form.submit
Expand All @@ -110,7 +110,7 @@
end

describe "Variants purpose" do
it "creates the box and its samples" do
it "creates the box and its samples", js: true do
goto_page NewBoxPage do |form|
form.fill(purpose: "Variants", media: media, option: "add_batches")
form.add_batch(virus_1, concentrations: [[2, 10]])
Expand All @@ -129,7 +129,7 @@
end
end

it "validates that we selected at least two unique batches" do
it "validates that we selected at least two unique batches", js: true do
goto_page NewBoxPage do |form|
form.fill(purpose: "Variants", media: media, option: "add_batches")
form.add_batch(virus_1, concentrations: [[1, 10]])
Expand All @@ -156,7 +156,7 @@
end

describe "Challenge purpose" do
it "creates the box and its samples" do
it "creates the box and its samples", js: true do
goto_page NewBoxPage do |form|
form.fill(purpose: "Challenge", option: "add_batches")
form.add_batch(virus_1, concentrations: [[2, 10]])
Expand All @@ -176,7 +176,7 @@
end
end

it "validates that we selected at least one distractor batch" do
it "validates that we selected at least one distractor batch", js: true do
goto_page NewBoxPage do |form|
form.fill(purpose: "Challenge", media: media, option: "add_batches")
form.add_batch(virus_1, concentrations: [[1, 10]])
Expand All @@ -199,7 +199,7 @@
end
end

it "validates that we selected at least one virus batch" do
it "validates that we selected at least one virus batch", js: true do
goto_page NewBoxPage do |form|
form.fill(purpose: "Challenge", media: media, option: "add_batches")
form.add_batch(distractor_1, concentrations: [[1, 10]], distractor: true)
Expand Down Expand Up @@ -237,7 +237,7 @@
end

describe "Other purpose" do
it "creates the box and its samples" do
it "creates the box and its samples", js: true do
goto_page NewBoxPage do |form|
form.fill(purpose: "Other", media: media, option: "add_batches")
form.add_batch(virus_1, concentrations: [[1, 10], [2, 100]])
Expand All @@ -255,7 +255,7 @@
end
end

it "requires at least one batch" do
it "requires at least one batch", js: true do
goto_page NewBoxPage do |form|
form.fill(purpose: "Other", media: media, option: "add_batches")
form.submit
Expand All @@ -277,7 +277,7 @@
let(:sample_3) { Sample.make!(:filled, institution: institution, batch: distractor_1, distractor: true) }
let(:sample_qc) { Sample.make!(:filled, institution: institution, specimen_role: "q") }

it "adds and removes samples" do
it "adds and removes samples", js: true do
goto_page NewBoxPage do |form|
form.fill(option: "add_samples")

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

it "creates an Other box" do
it "creates an Other box", js: true do
goto_page NewBoxPage do |form|
form.fill(purpose: "Other", media: media, option: "add_samples")
form.add_sample(sample_1)
Expand All @@ -317,7 +317,7 @@
end
end

it "requires at least one sample" do
it "requires at least one sample", js: true do
goto_page NewBoxPage do |form|
form.fill(purpose: purpose, media: media, option: "add_samples")
form.submit
Expand All @@ -330,15 +330,15 @@
end
end

it "can't select a QC sample" do
it "can't select a QC sample", js: true do
goto_page NewBoxPage do |form|
form.fill(purpose: purpose, media: media, option: "add_samples")
form.add_sample(sample_qc)
expect(form.sample_summaries.size).to eq(0)
end
end

it "can't create Challenge box without virus sample" do
it "can't create Challenge box without virus sample", js: true do
goto_page NewBoxPage do |form|
form.fill(purpose: "Challenge", media: media, option: "add_samples")
form.add_sample(sample_1)
Expand All @@ -353,7 +353,7 @@
end
end

it "can't create Challenge box without distractor sample" do
it "can't create Challenge box without distractor sample", js: true do
goto_page NewBoxPage do |form|
form.fill(purpose: "Challenge", media: media, option: "add_samples")
form.add_sample(sample_3)
Expand All @@ -368,7 +368,7 @@
end
end

it "can't create Variants box without samples from two batches" do
it "can't create Variants box without samples from two batches", js: true do
goto_page NewBoxPage do |form|
form.fill(purpose: "Variants", media: media, option: "add_samples")
form.add_sample(sample_1)
Expand All @@ -388,7 +388,7 @@
let!(:virus) { Batch.make!(institution: institution, batch_number: "VIRUS") }
let!(:distractor) { Batch.make!(institution: institution, batch_number: "DISTRACTOR") }

it "creates samples as defined by the CSV" do
it "creates samples as defined by the CSV", js: true do
goto_page NewBoxPage do |form|
form.fill(purpose: "LOD", media: media, option: "add_csv")
form.add_csv_file("csv_box_2.csv")
Expand Down
4 changes: 2 additions & 2 deletions spec/features/deleted_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
end
}

it "should be able to access site" do
it "should be able to access site", js: true do
click_link site.name

expect_page SiteEditPage do |page|
expect(page.shows_deleted?).to be_truthy
end
end

it "should be able to access device" do
it "should be able to access device", js: true do
click_link device.name

expect_page DevicePage do |page|
Expand Down
2 changes: 1 addition & 1 deletion spec/features/device_model_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
let(:user) { Institution.make!(:manufacturer).user }
before(:each) { sign_in(user) }

it "can create model and access to it's details" do
it "can create model and access to it's details", js: true do
goto_page NewDeviceModelPage do |page|
page.name.set "MyModel"
page.support_url.set "example.org/support"
Expand Down
22 changes: 11 additions & 11 deletions spec/features/device_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
sign_in(user)
}

it "can access if allowed" do
it "can access if allowed", js: true do
grant other_institution.user, user, Device, [READ_DEVICE]
grant other_institution.user, user, other_institution, [REGISTER_INSTITUTION_DEVICE]

Expand Down Expand Up @@ -52,7 +52,7 @@ def create_device
context "with a single site" do
let!(:site) { Site.make! institution: other_institution }

it "should assign the device to the sole site" do
it "should assign the device to the sole site", js: true do
expect(create_device.site).to eq(site)
end
end
Expand All @@ -61,11 +61,11 @@ def create_device
let!(:site) { Site.make! institution: other_institution }
let!(:site2) { Site.make! institution: other_institution }

it "should assign the device to no site" do
it "should assign the device to no site", js: true do
expect(create_device.site).to be_nil
end

it "should be able to specify a site" do
it "should be able to specify a site", js: true do
device = create_device do |page|
page.site.set site2.name
end
Expand All @@ -81,7 +81,7 @@ def create_device
let(:user) { Institution.make!(:manufacturer).user }
before(:each) { sign_in(user) }

it "can create model with activation and device get a token" do
it "can create model with activation and device get a token", js: true do
goto_page NewDeviceModelPage do |page|
page.name.set "MyModel"
page.support_url.set "example.org/support"
Expand All @@ -105,7 +105,7 @@ def create_device
end
end

it "can create model without activation and device show a secret ket only once" do
it "can create model without activation and device show a secret ket only once", js: true do
goto_page NewDeviceModelPage do |page|
page.name.set "MyModel"
page.support_url.set "example.org/support"
Expand Down Expand Up @@ -154,7 +154,7 @@ def create_device
sign_in(user)
}

it "shows online support_url in setup tab for activated device" do
it "shows online support_url in setup tab for activated device", js: true do
process

expect(device).to be_activated
Expand All @@ -169,7 +169,7 @@ def create_device
expect(current_url).to eq(device_model.support_url)
end

it "shows online support_url directly for non activated device" do
it "shows online support_url directly for non activated device", js: true do
expect(device).to_not be_activated

goto_page DevicePage, id: device.id
Expand All @@ -183,7 +183,7 @@ def create_device
expect(current_url).to eq(device_model.support_url)
end

it "shows tests processed by device event without name" do
it "shows tests processed by device event without name", js: true do
process
process_plain test: {assays:[condition: "flu_a", result: "positive"]}

Expand Down Expand Up @@ -220,7 +220,7 @@ def create_device
end
}

it "test details can be views if device is deleted" do
it "test details can be views if device is deleted", js: true do
goto_page TestResultsPage do |page|
page.table.items.first.click
expect(page.content).to have_content("Patient Arthur Miller")
Expand All @@ -245,7 +245,7 @@ def create_device
sign_in(user)
}

it "can process same message payload successfully after moving" do
it "can process same message payload successfully after moving", js: true do
goto_page SiteEditPage, site_id: site.id, query: { context: institution.uuid } do |page|
page.parent_site.set new_parent.name
page.submit
Expand Down
Loading

0 comments on commit eff732a

Please sign in to comment.