From 3d09f85023edb4322d6301f34f61b2793be75942 Mon Sep 17 00:00:00 2001 From: Joaquin Correa Date: Mon, 3 Feb 2025 15:50:11 -0300 Subject: [PATCH 1/8] Allow to specify reserved cells --- .../vue_well_plate_editor_app.js | 24 ++++++++++++++++--- .../sanger_sequencing/well_plate_builder.js | 2 +- .../admin/batches_controller.rb | 7 +++++- .../models/sanger_sequencing/batch_form.rb | 8 +++++++ .../well_plate_configuration.rb | 9 ++----- .../admin/batches/new.html.haml | 9 +++++-- .../sanger_sequencing/config/locales/en.yml | 1 + 7 files changed, 46 insertions(+), 14 deletions(-) diff --git a/vendor/engines/sanger_sequencing/app/assets/javascripts/sanger_sequencing/vue_well_plate_editor_app.js b/vendor/engines/sanger_sequencing/app/assets/javascripts/sanger_sequencing/vue_well_plate_editor_app.js index 1634d6c75c..3220a17caa 100644 --- a/vendor/engines/sanger_sequencing/app/assets/javascripts/sanger_sequencing/vue_well_plate_editor_app.js +++ b/vendor/engines/sanger_sequencing/app/assets/javascripts/sanger_sequencing/vue_well_plate_editor_app.js @@ -4,18 +4,22 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md */ window.vue_sanger_sequencing_well_plate_editor_app = { - props: ["submissions", "builder_config"], + props: ["submissions"], data() { return { builder: new SangerSequencing.WellPlateBuilder, - columnOrder: null + columnOrder: null, + reservedCells: [], }; }, beforeCompile() { this.colorBuilder = new SangerSequencing.WellPlateColors(this.builder); - return this.builder.setReservedCells(this.builder_config.reserved_cells); + }, + + compiled() { + this.initReservedCellsInput(); }, ready() { @@ -27,6 +31,10 @@ window.vue_sanger_sequencing_well_plate_editor_app = { this.builder.changeOrderStrategy(this.columnOrder); }, + updateReservedCells(values) { + this.builder.setReservedCells(values || []); + }, + addSubmission(submissionId) { return this.builder.addSubmission(this.findSubmission(submissionId)); }, @@ -55,6 +63,16 @@ window.vue_sanger_sequencing_well_plate_editor_app = { isNotInPlate(submissionId) { return !this.isInPlate(submissionId); + }, + initReservedCellsInput() { + let self = this; + + setTimeout(function() { + let comp = $(self.$els.reservedCells); + self.updateReservedCells(comp.val()); + + comp.chosen().on("change", () => self.updateReservedCells(comp.val())); + }, 0); } } diff --git a/vendor/engines/sanger_sequencing/app/assets/javascripts/sanger_sequencing/well_plate_builder.js b/vendor/engines/sanger_sequencing/app/assets/javascripts/sanger_sequencing/well_plate_builder.js index 2116553020..9a7d0ca3af 100644 --- a/vendor/engines/sanger_sequencing/app/assets/javascripts/sanger_sequencing/well_plate_builder.js +++ b/vendor/engines/sanger_sequencing/app/assets/javascripts/sanger_sequencing/well_plate_builder.js @@ -24,7 +24,7 @@ exports.SangerSequencing.WellPlateBuilder = class WellPlateBuilder { // This array maintains all of the submissions that have ever been added // in order to keep consistent colors when removing and adding samples. this.allSubmissions = []; - this._reservedCells = ["A01", "A02"]; + this._reservedCells = []; this._orderingStrategy = new SangerSequencing.OddFirstOrderingStrategy; this._render(); } diff --git a/vendor/engines/sanger_sequencing/app/controllers/sanger_sequencing/admin/batches_controller.rb b/vendor/engines/sanger_sequencing/app/controllers/sanger_sequencing/admin/batches_controller.rb index 02caa7922b..bc81b54c21 100644 --- a/vendor/engines/sanger_sequencing/app/controllers/sanger_sequencing/admin/batches_controller.rb +++ b/vendor/engines/sanger_sequencing/app/controllers/sanger_sequencing/admin/batches_controller.rb @@ -26,7 +26,6 @@ def new .includes(:samples, order_detail: :product) .for_facility(current_facility) .for_product_group(product_group) - @builder_config = WellPlateConfiguration.find(product_group) end def create @@ -86,6 +85,12 @@ def order_options helper_method :order_options + def reserved_cells_options + ["A01", "A02"] + end + + helper_method :reserved_cells_options + private def product_group diff --git a/vendor/engines/sanger_sequencing/app/models/sanger_sequencing/batch_form.rb b/vendor/engines/sanger_sequencing/app/models/sanger_sequencing/batch_form.rb index 1ddb844aeb..9e2ae5895a 100644 --- a/vendor/engines/sanger_sequencing/app/models/sanger_sequencing/batch_form.rb +++ b/vendor/engines/sanger_sequencing/app/models/sanger_sequencing/batch_form.rb @@ -17,6 +17,8 @@ class BatchForm attribute :batch attribute :column_order, default: "odd_first" + attr_writer :reserved_cells + delegate :submission_ids, :group, to: :batch validates :submission_ids, presence: true @@ -49,6 +51,12 @@ def save batch.save if valid? end + def reserved_cells + return @reserved_cells if @reserved_cells.present? + + WellPlateConfiguration.find(group).reserved_cells + end + private def submissions_in_correct_facility diff --git a/vendor/engines/sanger_sequencing/app/models/sanger_sequencing/well_plate_configuration.rb b/vendor/engines/sanger_sequencing/app/models/sanger_sequencing/well_plate_configuration.rb index 58925bdbab..2bdca68f50 100644 --- a/vendor/engines/sanger_sequencing/app/models/sanger_sequencing/well_plate_configuration.rb +++ b/vendor/engines/sanger_sequencing/app/models/sanger_sequencing/well_plate_configuration.rb @@ -4,6 +4,8 @@ module SangerSequencing class WellPlateConfiguration + attr_reader :reserved_cells + def initialize(reserved_cells: []) @reserved_cells = reserved_cells end @@ -16,13 +18,6 @@ def initialize(reserved_cells: []) def self.find(key) CONFIGS[key] || CONFIGS[:default] end - - def to_json - { - reserved_cells: Array(@reserved_cells), - }.to_json - end - end end diff --git a/vendor/engines/sanger_sequencing/app/views/sanger_sequencing/admin/batches/new.html.haml b/vendor/engines/sanger_sequencing/app/views/sanger_sequencing/admin/batches/new.html.haml index 2f0524fbe0..26eedb9ef2 100644 --- a/vendor/engines/sanger_sequencing/app/views/sanger_sequencing/admin/batches/new.html.haml +++ b/vendor/engines/sanger_sequencing/app/views/sanger_sequencing/admin/batches/new.html.haml @@ -5,7 +5,7 @@ = javascript_include_tag "sanger_sequencing/well_plate" = stylesheet_link_tag "sanger_sequencing/application" -%vue-sanger-sequencing-well-plate-editor-app(inline-template){ ":submissions" => @submissions.to_json(include: :samples), ":builder_config" => @builder_config.to_json } +%vue-sanger-sequencing-well-plate-editor-app(inline-template){ ":submissions" => @submissions.to_json(include: :samples) } = simple_form_for :batch, url: facility_sanger_sequencing_admin_batches_path do |f| = f.input :group, as: :hidden @@ -18,7 +18,12 @@ collection: order_options, include_blank: false, label: SangerSequencing::BatchForm.human_attribute_name(:column_order), - input_html: { "v-on:change": "changeOrder()", "v-model" => "columnOrder" } + input_html: { "v-on:change": "changeOrder()", "v-model": "columnOrder" } + + = f.input :reserved_cells, + collection: reserved_cells_options, + label: SangerSequencing::BatchForm.human_attribute_name(:reserved_cells), + input_html: { multiple: true, "v-el:reserved-cells": true } = f.submit text("submit"), class: "btn btn-primary" diff --git a/vendor/engines/sanger_sequencing/config/locales/en.yml b/vendor/engines/sanger_sequencing/config/locales/en.yml index aedba8413e..a7b8d3964a 100644 --- a/vendor/engines/sanger_sequencing/config/locales/en.yml +++ b/vendor/engines/sanger_sequencing/config/locales/en.yml @@ -111,6 +111,7 @@ en: attributes: sanger_sequencing/batch_form: column_order: Column Order + reserved_cells: Reserved Cells errors: models: sanger_sequencing/batch_form: From d33015349208b050518dc9e36b7018ecae662672 Mon Sep 17 00:00:00 2001 From: Joaquin Correa Date: Mon, 3 Feb 2025 16:49:25 -0300 Subject: [PATCH 2/8] Handle disabled flag --- .../sanger_sequencing/vue_well_plate_editor_app.js | 10 +++++++--- .../sanger_sequencing/admin/batches/new.html.haml | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/vendor/engines/sanger_sequencing/app/assets/javascripts/sanger_sequencing/vue_well_plate_editor_app.js b/vendor/engines/sanger_sequencing/app/assets/javascripts/sanger_sequencing/vue_well_plate_editor_app.js index 3220a17caa..57826af53b 100644 --- a/vendor/engines/sanger_sequencing/app/assets/javascripts/sanger_sequencing/vue_well_plate_editor_app.js +++ b/vendor/engines/sanger_sequencing/app/assets/javascripts/sanger_sequencing/vue_well_plate_editor_app.js @@ -4,7 +4,7 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md */ window.vue_sanger_sequencing_well_plate_editor_app = { - props: ["submissions"], + props: ["submissions", "defaultReservedCells"], data() { return { @@ -19,6 +19,7 @@ window.vue_sanger_sequencing_well_plate_editor_app = { }, compiled() { + this.updateReservedCells(this.defaultReservedCells); this.initReservedCellsInput(); }, @@ -69,9 +70,12 @@ window.vue_sanger_sequencing_well_plate_editor_app = { setTimeout(function() { let comp = $(self.$els.reservedCells); - self.updateReservedCells(comp.val()); - comp.chosen().on("change", () => self.updateReservedCells(comp.val())); + if (comp.length) { + self.updateReservedCells(comp.val()); + + comp.chosen().on("change", () => self.updateReservedCells(comp.val())); + } }, 0); } } diff --git a/vendor/engines/sanger_sequencing/app/views/sanger_sequencing/admin/batches/new.html.haml b/vendor/engines/sanger_sequencing/app/views/sanger_sequencing/admin/batches/new.html.haml index 26eedb9ef2..75ad25966e 100644 --- a/vendor/engines/sanger_sequencing/app/views/sanger_sequencing/admin/batches/new.html.haml +++ b/vendor/engines/sanger_sequencing/app/views/sanger_sequencing/admin/batches/new.html.haml @@ -5,7 +5,7 @@ = javascript_include_tag "sanger_sequencing/well_plate" = stylesheet_link_tag "sanger_sequencing/application" -%vue-sanger-sequencing-well-plate-editor-app(inline-template){ ":submissions" => @submissions.to_json(include: :samples) } +%vue-sanger-sequencing-well-plate-editor-app(inline-template){ ":submissions" => @submissions.to_json(include: :samples), ":default-reserved-cells" => @batch.reserved_cells } = simple_form_for :batch, url: facility_sanger_sequencing_admin_batches_path do |f| = f.input :group, as: :hidden From a2e53597630ac6b6aa071bb9bcdcc69b7cd53a03 Mon Sep 17 00:00:00 2001 From: Joaquin Correa Date: Mon, 3 Feb 2025 18:09:30 -0300 Subject: [PATCH 3/8] Add specs --- .../system/batches/creating_a_batch_spec.rb | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/vendor/engines/sanger_sequencing/spec/system/batches/creating_a_batch_spec.rb b/vendor/engines/sanger_sequencing/spec/system/batches/creating_a_batch_spec.rb index 638a8a25ca..4a988ce038 100644 --- a/vendor/engines/sanger_sequencing/spec/system/batches/creating_a_batch_spec.rb +++ b/vendor/engines/sanger_sequencing/spec/system/batches/creating_a_batch_spec.rb @@ -3,7 +3,7 @@ require "rails_helper" require_relative "../../support/shared_contexts/setup_sanger_service" -RSpec.describe "Creating a batch", :js do +RSpec.describe "Creating a batch", :js, feature_setting: { sanger_sequencing_enabled: false } do include_context "Setup Sanger Service" let!(:purchased_order) { create(:purchased_order, product: service, account: account) } @@ -62,6 +62,45 @@ def click_add(submission_id) end end + describe "plate reserved cells selection", feature_setting: { sanger_enabled_service: true } do + let!(:submission) do + create( + :sanger_sequencing_submission, + order_detail: purchased_order.order_details.first, + sample_count: 14 + ) + end + let(:batch) { submission.reload.batch } + + it "can select reserved cells" do + visit new_facility_sanger_sequencing_admin_batch_path(facility) + + expect(page).to have_content("Reserved Cells") + + select_from_chosen("A01", from: "batch[reserved_cells][]") + + click_add(submission.id) + + click_button("Save Batch") + + expect(batch.sample_at(0, "A01")).to be_reserved + end + + it "can unselect reserved cells" do + visit new_facility_sanger_sequencing_admin_batch_path(facility) + + expect(page).to have_content("Reserved Cells") + + unselect_from_chosen("A01", from: "batch[reserved_cells][]") + + click_add(submission.id) + + click_button "Save Batch" + + expect(batch.sample_at(0, "A01")).to eq(submission.samples.first) + end + end + describe "creating a well-plate" do before do visit facility_sanger_sequencing_admin_batches_path(facility) From 53dc06fd0e6190be0c23b87c0081f2d2301e0175 Mon Sep 17 00:00:00 2001 From: Joaquin Correa Date: Mon, 3 Feb 2025 18:18:44 -0300 Subject: [PATCH 4/8] Update chosen helper --- spec/support/select_from_chosen.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec/support/select_from_chosen.rb b/spec/support/select_from_chosen.rb index 1a65282b59..f5286c2a0b 100644 --- a/spec/support/select_from_chosen.rb +++ b/spec/support/select_from_chosen.rb @@ -12,4 +12,11 @@ def select_from_chosen(item_text, options) find("##{field[:id]}_chosen ul.chosen-results li", text: item_text).click end + def unselect_from_chosen(item_text, options) + page.scroll_to(options[:scroll_to]) if options[:scroll_to] + + field = find_field(options[:from], visible: false) + find("##{field[:id]}_chosen li.search-choice", text: item_text).find(".search-choice-close").click + end + end From 16149ae04b2f104fbda4f39a93716b07b6104875 Mon Sep 17 00:00:00 2001 From: Joaquin Correa Date: Tue, 4 Feb 2025 10:09:47 -0300 Subject: [PATCH 5/8] Decaffeinate well_plate_builder_spec --- .../well_plate_builder_spec.js | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 vendor/engines/sanger_sequencing/spec/javascripts/sanger_sequencing/well_plate_builder_spec.js diff --git a/vendor/engines/sanger_sequencing/spec/javascripts/sanger_sequencing/well_plate_builder_spec.js b/vendor/engines/sanger_sequencing/spec/javascripts/sanger_sequencing/well_plate_builder_spec.js new file mode 100644 index 0000000000..79a9310956 --- /dev/null +++ b/vendor/engines/sanger_sequencing/spec/javascripts/sanger_sequencing/well_plate_builder_spec.js @@ -0,0 +1,184 @@ +/* + * decaffeinate suggestions: + * DS102: Remove unnecessary code created because of implicit returns + * DS202: Simplify dynamic range loops + * DS205: Consider reworking code to avoid use of IIFEs + * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md + */ +//= require sanger_sequencing/well_plate + +describe("SangerSequencing.WellPlateBuilder", function() { + const sampleList = function(count) { + if (this.lastSampleId === undefined) { this.lastSampleId = 0; } + return (() => { + const result = []; + for (let x = 0, end = count, asc = 0 <= end; asc ? x < end : x > end; asc ? x++ : x--) { + this.lastSampleId++; + result.push(new SangerSequencing.Sample({id: this.lastSampleId, customer_sample_id: `Testing ${x}`})); + } + return result; + })(); + }; + + describe("addSubmission()", function() { + beforeEach(function() { + this.submission = { id: 542, samples: sampleList(2) }; + return this.wellPlate = new SangerSequencing.WellPlateBuilder; + }); + + it("can add a submission", function() { + this.wellPlate.addSubmission(this.submission); + return expect(this.wellPlate.submissions).toEqual([this.submission]); + }); + + return it("cannot add a submission twice", function() { + this.wellPlate.addSubmission(this.submission); + this.wellPlate.addSubmission(this.submission); + return expect(this.wellPlate.submissions).toEqual([this.submission]); + }); + }); + + describe("removeSubmission()", function() { + beforeEach(function() { + this.wellPlate = new SangerSequencing.WellPlateBuilder; + this.submission1 = { id: 542, samples: sampleList(2) }; + this.submission2 = { id: 543, samples: sampleList(3) }; + this.wellPlate.addSubmission(this.submission1); + return this.wellPlate.addSubmission(this.submission2); + }); + + return it("can remove a submission", function() { + this.wellPlate.removeSubmission(this.submission1); + return expect(this.wellPlate.submissions).toEqual([this.submission2]); + }); + }); + + describe("samples()", function() { + beforeEach(function() { + this.wellPlate = new SangerSequencing.WellPlateBuilder; + this.submission1 = { id: 542, samples: sampleList(2) }; + this.submission2 = { id: 543, samples: sampleList(3) }; + this.wellPlate.addSubmission(this.submission1); + return this.wellPlate.addSubmission(this.submission2); + }); + + return it("returns the samples in order", function() { + return expect(this.wellPlate.samples()).toEqual(this.submission1.samples.concat(this.submission2.samples)); + }); + }); + + describe("sampleAtCell()", function() { + beforeEach(function() { + this.wellPlate = new SangerSequencing.WellPlateBuilder; + this.submission1 = { id: 542, samples: sampleList(2) }; + this.submission2 = { id: 543, samples: sampleList(3) }; + this.wellPlate.addSubmission(this.submission1); + return this.wellPlate.addSubmission(this.submission2); + }); + + it("finds the first sample at B01 (because the A01 is blank", function() { + return expect(this.wellPlate.sampleAtCell("B01")).toEqual(this.submission1.samples[0]); + }); + + return describe("when it rolls over into a second plate", function() { + beforeEach(function() { + this.submission3 = { id: 544, samples: sampleList(92) }; + return this.wellPlate.addSubmission(this.submission3); + }); + + it("finds the first sample at B01", function() { + return expect(this.wellPlate.sampleAtCell("B01", 0)).toEqual(this.submission1.samples[0]); + }); + + return it("finds the sample in the second plate at B01", function() { + // 89 because 96 - 5(already added) - 2 (reserved) = 89 + return expect(this.wellPlate.sampleAtCell("B01", 1)).toEqual(this.submission3.samples[89]); + }); + }); + }); + + describe("plateCount()", function() { + beforeEach(function() { + return this.wellPlate = new SangerSequencing.WellPlateBuilder; + }); + + it("has one plate when empty", function() { + return expect(this.wellPlate.plateCount()).toEqual(1); + }); + + it("has one plate when less than 96 cells", function() { + this.submission = { id: 542, samples: sampleList(40) }; + this.wellPlate.addSubmission(this.submission); + return expect(this.wellPlate.plateCount()).toEqual(1); + }); + + it("has one plates when it is completely full", function() { + this.submission = { id: 542, samples: sampleList(94) }; + this.wellPlate.addSubmission(this.submission); + return expect(this.wellPlate.plateCount()).toEqual(1); + }); + + it("has two plates when it is just over full", function() { + this.submission = { id: 542, samples: sampleList(95) }; + this.wellPlate.addSubmission(this.submission); + return expect(this.wellPlate.plateCount()).toEqual(2); + }); + + return it("has three plates when it gets really big", function() { + this.submission = { id: 542, samples: sampleList(280) }; + this.wellPlate.addSubmission(this.submission); + return expect(this.wellPlate.plateCount()).toEqual(3); + }); + }); + + return describe("plates", function() { + beforeEach(function() { + this.wellPlate = new SangerSequencing.WellPlateBuilder; + this.submission = { id: 542, samples: sampleList(8) }; + return this.wellPlate.addSubmission(this.submission); + }); + + it("has 96 cells", function() { + const results = this.wellPlate.plates[0]; + return expect(Object.keys(results).length).toEqual(96); + }); + + return it("renders odd rows first", function() { + const results = this.wellPlate.plates[0]; + return (() => { + const result = []; + for (var expected of [ + ["A01", "reserved" ], + ["B01", "Testing 0" ], + ["C01", "Testing 1" ], + ["D01", "Testing 2" ], + ["E01", "Testing 3" ], + ["F01", "Testing 4" ], + ["G01", "Testing 5" ], + ["H01", "Testing 6" ], + ["A02", "reserved" ], + ["B02", "" ], + ["C02", "" ], + ["D02", "" ], + ["E02", "" ], + ["F02", "" ], + ["G02", "" ], + ["H02", "" ], + ["A03", "Testing 7" ], + ["B03", "" ], + ["C03", "" ], + ["D03", "" ], + ["E03", "" ], + ["F03", "" ], + ["G03", "" ], + ["H03", "" ], + ]) { + var well = expected[0]; + var value = expected[1]; + result.push(expect(results[well].customerSampleId()).toEqual(value)); + } + return result; + })(); + }); + }); +}); From fbd330733d310f6a16e816e5d508af2d11721335 Mon Sep 17 00:00:00 2001 From: Joaquin Correa Date: Tue, 4 Feb 2025 10:12:38 -0300 Subject: [PATCH 6/8] Fix well plate builder specs --- .../well_plate_builder_spec.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/vendor/engines/sanger_sequencing/spec/javascripts/sanger_sequencing/well_plate_builder_spec.js b/vendor/engines/sanger_sequencing/spec/javascripts/sanger_sequencing/well_plate_builder_spec.js index 79a9310956..80f68b2a46 100644 --- a/vendor/engines/sanger_sequencing/spec/javascripts/sanger_sequencing/well_plate_builder_spec.js +++ b/vendor/engines/sanger_sequencing/spec/javascripts/sanger_sequencing/well_plate_builder_spec.js @@ -23,7 +23,8 @@ describe("SangerSequencing.WellPlateBuilder", function() { describe("addSubmission()", function() { beforeEach(function() { this.submission = { id: 542, samples: sampleList(2) }; - return this.wellPlate = new SangerSequencing.WellPlateBuilder; + this.wellPlate = new SangerSequencing.WellPlateBuilder; + this.wellPlate.setReservedCells(["A01", "A02"]); }); it("can add a submission", function() { @@ -41,6 +42,7 @@ describe("SangerSequencing.WellPlateBuilder", function() { describe("removeSubmission()", function() { beforeEach(function() { this.wellPlate = new SangerSequencing.WellPlateBuilder; + this.wellPlate.setReservedCells(["A01", "A02"]); this.submission1 = { id: 542, samples: sampleList(2) }; this.submission2 = { id: 543, samples: sampleList(3) }; this.wellPlate.addSubmission(this.submission1); @@ -56,6 +58,7 @@ describe("SangerSequencing.WellPlateBuilder", function() { describe("samples()", function() { beforeEach(function() { this.wellPlate = new SangerSequencing.WellPlateBuilder; + this.wellPlate.setReservedCells(["A01", "A02"]); this.submission1 = { id: 542, samples: sampleList(2) }; this.submission2 = { id: 543, samples: sampleList(3) }; this.wellPlate.addSubmission(this.submission1); @@ -70,16 +73,22 @@ describe("SangerSequencing.WellPlateBuilder", function() { describe("sampleAtCell()", function() { beforeEach(function() { this.wellPlate = new SangerSequencing.WellPlateBuilder; + this.wellPlate.setReservedCells(["A01", "A02"]); this.submission1 = { id: 542, samples: sampleList(2) }; this.submission2 = { id: 543, samples: sampleList(3) }; this.wellPlate.addSubmission(this.submission1); return this.wellPlate.addSubmission(this.submission2); }); - it("finds the first sample at B01 (because the A01 is blank", function() { + it("finds the first sample at B01 when A01 is reserved", function() { return expect(this.wellPlate.sampleAtCell("B01")).toEqual(this.submission1.samples[0]); }); + it("finds the first sample at B01 when A01 is not reserved", function() { + this.wellPlate.setReservedCells([]); + return expect(this.wellPlate.sampleAtCell("A01")).toEqual(this.submission1.samples[0]); + }); + return describe("when it rolls over into a second plate", function() { beforeEach(function() { this.submission3 = { id: 544, samples: sampleList(92) }; @@ -99,7 +108,8 @@ describe("SangerSequencing.WellPlateBuilder", function() { describe("plateCount()", function() { beforeEach(function() { - return this.wellPlate = new SangerSequencing.WellPlateBuilder; + this.wellPlate = new SangerSequencing.WellPlateBuilder; + this.wellPlate.setReservedCells(["A01", "A02"]); }); it("has one plate when empty", function() { @@ -134,6 +144,7 @@ describe("SangerSequencing.WellPlateBuilder", function() { return describe("plates", function() { beforeEach(function() { this.wellPlate = new SangerSequencing.WellPlateBuilder; + this.wellPlate.setReservedCells(["A01", "A02"]); this.submission = { id: 542, samples: sampleList(8) }; return this.wellPlate.addSubmission(this.submission); }); From feb9764397b7edbe91e70f9caada35bc1d48ff5f Mon Sep 17 00:00:00 2001 From: Joaquin Correa Date: Tue, 4 Feb 2025 10:22:09 -0300 Subject: [PATCH 7/8] Add test with ff off --- .../spec/system/batches/creating_a_batch_spec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vendor/engines/sanger_sequencing/spec/system/batches/creating_a_batch_spec.rb b/vendor/engines/sanger_sequencing/spec/system/batches/creating_a_batch_spec.rb index 4a988ce038..25d0c301e1 100644 --- a/vendor/engines/sanger_sequencing/spec/system/batches/creating_a_batch_spec.rb +++ b/vendor/engines/sanger_sequencing/spec/system/batches/creating_a_batch_spec.rb @@ -99,6 +99,15 @@ def click_add(submission_id) expect(batch.sample_at(0, "A01")).to eq(submission.samples.first) end + + it( + "does not show the input when the flag is off", + feature_setting: { sanger_sequencing_enabled: false } + ) do + visit new_facility_sanger_sequencing_admin_batch_path(facility) + + expect(page).to_not have_content("Reserved Cells") + end end describe "creating a well-plate" do From 0b5bb571127007f1d4b8d3d5ad47886686058b80 Mon Sep 17 00:00:00 2001 From: Joaquin Correa Date: Tue, 4 Feb 2025 10:31:18 -0300 Subject: [PATCH 8/8] Improve ff off spec --- .../spec/system/batches/creating_a_batch_spec.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/vendor/engines/sanger_sequencing/spec/system/batches/creating_a_batch_spec.rb b/vendor/engines/sanger_sequencing/spec/system/batches/creating_a_batch_spec.rb index 25d0c301e1..951c19cc03 100644 --- a/vendor/engines/sanger_sequencing/spec/system/batches/creating_a_batch_spec.rb +++ b/vendor/engines/sanger_sequencing/spec/system/batches/creating_a_batch_spec.rb @@ -102,11 +102,20 @@ def click_add(submission_id) it( "does not show the input when the flag is off", - feature_setting: { sanger_sequencing_enabled: false } + feature_setting: { sanger_enabled_service: false } ) do visit new_facility_sanger_sequencing_admin_batch_path(facility) - expect(page).to_not have_content("Reserved Cells") + within("form.batch") do + expect(page).to_not have_content("Reserved Cells") + end + + click_add(submission.id) + + click_button "Save Batch" + + expect(batch.sample_at(0, "A01")).to be_reserved + expect(batch.sample_at(0, "A02")).to be_blank end end