Skip to content

Commit

Permalink
Test batch creation with different column order
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquinco committed Jan 17, 2025
1 parent 86a0698 commit e1deed0
Showing 1 changed file with 47 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
RSpec.describe "Creating a batch", :js do
include_context "Setup Sanger Service"

let!(:purchased_order) { FactoryBot.create(:purchased_order, product: service, account: account) }
let!(:purchased_order2) { FactoryBot.create(:purchased_order, product: service, account: account) }
let!(:purchased_submission) { FactoryBot.create(:sanger_sequencing_submission, order_detail: purchased_order.order_details.first, sample_count: 50) }
let!(:purchased_submission2) { FactoryBot.create(:sanger_sequencing_submission, order_detail: purchased_order2.order_details.first, sample_count: 50) }
let!(:purchased_order) { create(:purchased_order, product: service, account: account) }
let!(:purchased_order2) { create(:purchased_order, product: service, account: account) }
let!(:purchased_submission) { create(:sanger_sequencing_submission, order_detail: purchased_order.order_details.first, sample_count: 50) }
let!(:purchased_submission2) { create(:sanger_sequencing_submission, order_detail: purchased_order2.order_details.first, sample_count: 50) }

let(:facility_staff) { FactoryBot.create(:user, :staff, facility: facility) }
let(:facility_staff) { create(:user, :staff, facility: facility) }

before { login_as facility_staff }

Expand All @@ -21,6 +21,47 @@ def click_add(submission_id)
end
end

describe "plate column order" do
let!(:submission) do
create(
:sanger_sequencing_submission,
order_detail: purchased_order.order_details.first,
sample_count: 14
)
end
let(:batch) { submission.reload.batch }

before do
visit new_facility_sanger_sequencing_admin_batch_path(facility)
end

it "can select odd first order" do
select("Half Plate", from: "batch[column_order]")

click_add(submission.id)

click_button "Save Batch"

expect(batch.sample_at(0, "A01")).to be_reserved
expect(batch.sample_at(0, "B01")).to eq(submission.samples.first)
expect(batch.sample_at(0, "B02")).to be_blank
expect(batch.sample_at(0, "G03")).to eq(submission.samples.last)
end

it "can select sequential order" do
select("Full Plate", from: "batch[column_order]")

click_add(submission.id)

click_button "Save Batch"

expect(batch.sample_at(0, "A01")).to be_reserved
expect(batch.sample_at(0, "B01")).to eq(submission.samples.first)
expect(batch.sample_at(0, "H02")).to eq(submission.samples.last)
expect(batch.sample_at(0, "B03")).to be_blank
end
end

describe "creating a well-plate" do
before do
visit facility_sanger_sequencing_admin_batches_path(facility)
Expand Down Expand Up @@ -48,7 +89,7 @@ def click_add(submission_id)
end

describe "creating a batch with a previously completed submission" do
let!(:completed_submission) { FactoryBot.create(:sanger_sequencing_submission, order_detail: purchased_order2.order_details.first, sample_count: 50) }
let!(:completed_submission) { create(:sanger_sequencing_submission, order_detail: purchased_order2.order_details.first, sample_count: 50) }

before do
purchased_order.order_details.first.to_complete
Expand Down

0 comments on commit e1deed0

Please sign in to comment.