Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[automated] Merge Develop into Master #1940

Merged
merged 95 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
f18dded
Use SS API v2 for getting BarcodePrinters
sdjmchattie Jul 23, 2024
095cc2f
Remove v1 barcode printer factories
sdjmchattie Jul 23, 2024
58625fa
Rename type_name to barcode_type
sdjmchattie Jul 23, 2024
4004e22
Remove unused test variable
sdjmchattie Jul 24, 2024
bc41bfc
Update the devour config file
sdjmchattie Jul 25, 2024
6440fb3
Remove v1 API from LabwareController
sdjmchattie Jul 26, 2024
8feebba
Put the api attribute back on Presenter for now
sdjmchattie Jul 26, 2024
e0a87c9
Merge pull request #1805 from sanger/Y24-190-2-use-ss-api-v2-for-chro…
sdjmchattie Jul 29, 2024
e49c4b2
Move the LabwareMetadata class over to using the V2 API
sdjmchattie Jul 29, 2024
8655a67
Update some tests with new API v2 helper methods
sdjmchattie Jul 29, 2024
4772f7a
Fix Rubocop concerns
sdjmchattie Jul 29, 2024
38f0809
Fix tests for quadrant split plate
sdjmchattie Jul 30, 2024
12dea35
Remove reference to custom_metadatum_collection from tube
sdjmchattie Jul 30, 2024
86d5934
Add classes for using v2 API TagLayoutTemplate
sdjmchattie Jul 31, 2024
b73aa7b
Start putting V2 tag layout template stubs/factories in place
sdjmchattie Jul 31, 2024
dff8746
Document the approach to stubbing relationships in V2 resources
sdjmchattie Aug 1, 2024
4fd7757
Remove the accidentally committed test debugging objects
sdjmchattie Aug 1, 2024
1d89cf7
Ensure tags generated for a tag_group point to the correct group
sdjmchattie Aug 1, 2024
4b82bbb
Fix relationships for tag layout templates in FactoryBot
sdjmchattie Aug 1, 2024
3306e6d
Fix tests for custom tagged plate spec
sdjmchattie Aug 1, 2024
b751825
Fix tests for tagged_plate_spec
sdjmchattie Aug 1, 2024
43b514b
Merge branch 'develop' into develop-Y24-190
sdjmchattie Aug 2, 2024
c4940a1
Remove unneeded stub
sdjmchattie Aug 2, 2024
cc2593b
Add a factory for a dual indexed tag layout template
sdjmchattie Aug 2, 2024
cbb3f58
Clean up the naming in shared examples
sdjmchattie Aug 2, 2024
3da27a2
Correctly name context blocks
sdjmchattie Aug 5, 2024
6bd2aec
Merge branch 'develop' into develop-Y24-190
sdjmchattie Aug 5, 2024
7b0759f
Assign correct class for tag2_group on tag_layout_template
sdjmchattie Aug 5, 2024
201fb5b
Merge page results when getting tag layout templates
sdjmchattie Aug 5, 2024
7e895d3
Add TODO about calling methods on resources
sdjmchattie Aug 6, 2024
d92ff39
Stub v2 TagLayoutTemplates with paging
sdjmchattie Aug 6, 2024
ef03d4b
Fix tests for creating_a_tag_plate_spec using V2
sdjmchattie Aug 6, 2024
98fa7a1
Fix final tests for tag_layout_templates move to V2
sdjmchattie Aug 6, 2024
dc38f39
Merge branch 'develop' into develop-Y24-190
sdjmchattie Aug 6, 2024
ff89668
Merge branch 'develop-Y24-190' into Y24-190-3-use-ss-v2-for-labware-c…
sdjmchattie Aug 8, 2024
4fc7eeb
Merge pull request #1835 from sanger/Y24-190-3-use-ss-v2-for-labware-…
sdjmchattie Aug 8, 2024
43221e8
Merge branch 'develop-Y24-190' into Y24-190-2-use-ss-v2-for-labware-m…
sdjmchattie Aug 9, 2024
fcceab7
Resolve remaining use of V1 API during Chromium pipeline
sdjmchattie Aug 9, 2024
9ef1a33
Fix tests for Presenters
sdjmchattie Aug 9, 2024
fee8b56
Pass a V2 tube to SimpleTubePresenter
sdjmchattie Aug 9, 2024
fbdafbc
Apply more fixes to tests
sdjmchattie Aug 9, 2024
b06fd07
Fix tests for PooledTubesBySubmission
sdjmchattie Aug 9, 2024
4b9cb28
Fix tests on QuadrantStampPrimerPanel
sdjmchattie Aug 9, 2024
ea5f990
Fix tests for plate transfer
sdjmchattie Aug 9, 2024
7bb36c9
Make Rubocop happy
sdjmchattie Aug 9, 2024
b3e4e1a
Fix tests for RobotsController and when pooling_multiple_tubes_into_o…
sdjmchattie Aug 12, 2024
ab1c8dd
Add the relationship to custom_metadatum_collection on tubes
sdjmchattie Aug 12, 2024
e93e79c
Add uuids to factory build custom_metadatum_collections
sdjmchattie Aug 12, 2024
999e3c1
Reference labware with an @ in CustomMetadatumCollection
sdjmchattie Aug 12, 2024
b5e751e
Associate custom_metadatum_collections correctly on V2 tube and plate…
sdjmchattie Aug 12, 2024
85020f9
Fix issues generated by not having a static barcode for stock plates
sdjmchattie Aug 12, 2024
cbd1433
Fix LabwareMetadata tests
sdjmchattie Aug 12, 2024
33f7d05
Merge branch 'develop' into develop-Y24-190
sdjmchattie Aug 12, 2024
680776d
Fix naming of memoized variable for transfer_template
sdjmchattie Aug 12, 2024
1e1a076
Don't check the type of source_plate
sdjmchattie Aug 14, 2024
64aa80f
Merge pull request #1847 from sanger/Y24-190-2-use-ss-v2-for-labware-…
sdjmchattie Aug 14, 2024
ed65da1
Merge branch 'develop' into develop-Y24-190
sdjmchattie Aug 16, 2024
7b694ba
Replace creation of Transfers via v1 with v2
sdjmchattie Aug 20, 2024
2356a35
Use correct name for the API v2 endpoint
sdjmchattie Aug 20, 2024
85d34cd
Pluralise the transfers attribute
sdjmchattie Aug 20, 2024
dd89b64
Indicate that Transfers are nested one layer deeper than other resources
sdjmchattie Aug 20, 2024
8df2472
Fix attribute reference when getting destination UUIDs via API v2
sdjmchattie Aug 20, 2024
24a1378
Use method mapping for destination_uuid
sdjmchattie Aug 20, 2024
a3e97eb
Use correct key when setting the destination of a transfer
sdjmchattie Aug 20, 2024
b900cfc
Fix further instances of child_uuid instead of destination_uuid
sdjmchattie Aug 21, 2024
775407c
Fix tests in three spec files
sdjmchattie Aug 21, 2024
4b9ca0d
Fix more tests
sdjmchattie Aug 22, 2024
ac6dfbe
Finish fixing tests in Limber
sdjmchattie Aug 22, 2024
30b85c0
Fix misnamed variable reference
sdjmchattie Aug 22, 2024
305a657
Fix remaining instances of changing persisted transfer template IDs a…
sdjmchattie Aug 22, 2024
842220c
Merge branch 'develop' into develop-Y24-190
sdjmchattie Aug 22, 2024
1dce9e9
build(deps): bump micromatch from 4.0.5 to 4.0.8
dependabot[bot] Aug 27, 2024
0d5e508
Merge pull request #1863 from sanger/Y24-190-3-use-v2-transfer-template
sdjmchattie Aug 29, 2024
99d5394
Switch to using API v2 for StateChange creations
sdjmchattie Aug 30, 2024
863651a
Update tests to expect API v2 StateChange creation
sdjmchattie Aug 30, 2024
bc222b7
Merge pull request #1882 from sanger/Y24-190-3-use-v2-state-change
sdjmchattie Sep 2, 2024
b2e1d16
Merge branch 'develop' into develop-Y24-190
sdjmchattie Sep 2, 2024
9b277c4
Merge branch 'develop' into develop-Y24-190
sdjmchattie Sep 4, 2024
130099e
Add new API v2 endpoints to resources.js
sdjmchattie Sep 4, 2024
630bf1e
Merge branch 'develop' into develop-Y24-190
sdjmchattie Sep 6, 2024
9cdcba4
set qc threshold of LRC PBMC Pools to 70%
sabrine33 Sep 9, 2024
ef2802e
Update postcss to version 8.4.47
depfu[bot] Sep 15, 2024
c841bbb
Merge branch 'develop' into develop-Y24-190
sdjmchattie Sep 17, 2024
ccdab1b
fix: restore removed data-plate-views
StephenHulme Sep 18, 2024
c957c0d
Add TSISC_UDI96 and TSRNAhWGS_UDI96 to LCMT EM Lib PCR config
yoldas Sep 18, 2024
c6476f7
Merge branch 'develop' of https://github.com/sanger/limber into DPL-9…
sabrine33 Sep 18, 2024
f4b2c65
Merge pull request #1906 from sanger/DPL-918-set-LRC-PBMC-pool-threshold
sabrine33 Sep 18, 2024
6ab9943
Merge pull request #1935 from sanger/y24-329-binning-colours-regression
StephenHulme Sep 18, 2024
3e23ee0
Merge pull request #1938 from sanger/y24-266-add-tag-layout-templates…
yoldas Sep 18, 2024
d90a388
Merge pull request #1877 from sanger/dependabot/npm_and_yarn/micromat…
StephenHulme Sep 19, 2024
c51a3fa
build: change eslint formatter to not use the buggy stylish
StephenHulme Sep 19, 2024
197bcc7
Merge pull request #1884 from sanger/develop-Y24-190
sdjmchattie Sep 19, 2024
b9b0ad3
Merge pull request #1923 from sanger/depfu/update/yarn/postcss-8.4.47
StephenHulme Sep 19, 2024
e80b039
Merge branch 'master' into develop
StephenHulme Sep 20, 2024
ea5e742
release: bump patch version
StephenHulme Sep 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.59.2
3.59.3
58 changes: 57 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,68 @@ There are a few tools available to assist with writing specs:

- Helpers: `with_has_many_associations` and `with_belongs_to_associations` can be used in factories to set up the relevant json. They won't actually mock up the relevant requests, but ensure that things like actions are defined so that the api knows where to find them.

#### Request stubbing
#### Request stubbing for the Sequencescape v1 API

Request stubs are provided by webmock. Two helper methods will assist with the majority of mocking requests to the api, `stub_api_get` and `stub_api_post`. See `spec/support/api_url_helper.rb` for details.

**Note**: Due to the way the api functions, the factories don't yet support nested associations.

#### Request stubbing for the Sequencescape v2 API

The V2 API uses `JsonApiClient::Resource` sub-classes to represent the records in memory.
Generally these are quite dynamic so you don't need to explicitly specify every property the API will respond with.
The base class also provides us with methods that are familiar to Rails for finding one or more records that match criteria.
So to stub the API, the easiest thing to do is to get FactoryBot to make up resources using the specific resource sub-class for the V2 API, and then mock the calls to those lookup methods.
Many of these have already been done for you in `spec/support/api_url_helper.rb` such as `stub_v2_study` and `stub_v2_tag_layout_templates` which sets up the `find` method for studies by name and the `all` method for tag layout templates, respectively.
However there's also `stub_api_v2_post`, `stub_api_v2_patch` and `stub_api_v2_save` which ensures that any calls to the `create`, `update` and the `save` method for resources of a particular type are expected and give a return value.
If none of the existing method suit your needs, you should add new ones.

##### FactoryBot is not mocking my related resources correctly

Nested relationships, such as Wells inside a Plate, the resource should indicate this with keywords like `has_one`, `has_many`, `belongs_to`, etc.
See the [json_api_client repository](https://github.com/JsonApiClient/json_api_client) for this topic and more.
However, FactoryBot does not get on well with some of these relationship methods and will not mock them properly using standard FactoryBot definitions.

If you find that FactoryBot is not giving you the expected resource for a related record, you can inject the related resource directly into the `JsonApiClient::Resource`'s cache of relationships.
To do that, define the related resource as a `transient` variable and use an `after(:build)` block to assign the resource to the `_cached_relationship` method.
For example, where the Resource might be defined as the following class:

```ruby
class Sequencescape::Api::V2::RootRecord < JsonApiClient::Resource
has_one :related_thing
end
```

You might expect to be able to use FactoryBot in the following way:

```ruby
FactoryBot.define do
factory :root_record, class: Sequencescape::Api::V2::RootRecord do
skip_create

related_thing { create :related_thing }
end
end
```

But the related thing will not be the one you defined to be generated by another factory.
It appears the `has_one` method in the resource over-rides the mocked value and you get an empty record back instead.
So, instead, you should create the `related_thing` record as a transient and assign it to the `root_record` in an `after(:build)` block as shown here.

```ruby
FactoryBot.define do
factory :root_record, class: Sequencescape::Api::V2::RootRecord do
skip_create

transient { related_thing { create :v2_tag_group_with_tags } }

after(:build) do |record, factory|
record._cached_relationship(:related_thing) { factory.related_thing } if evaluator.related_thing
end
end
end
```

#### Feature debugging

To help with debugging feature specs, temporarily comment out the line `options.add_argument('--headless')` in `spec/spec_helper.rb`. This will allow you to see the browser as the tests run. To pause the execution at certain point, possibly before an expected failure, insert `binding.pry` at the appropriate place in the spec.
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/labware_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ def locate_labware
end

def find_printers
@printers = api.barcode_printer.all
@printers = Sequencescape::Api::V2::BarcodePrinter.all
end

def state_changer_for(purpose_uuid, labware_uuid)
StateChangers.lookup_for(purpose_uuid).new(api, labware_uuid, current_user_uuid)
end

def presenter_for(labware)
Presenters.lookup_for(labware).new(api: api, labware: labware)
Presenters.lookup_for(labware).new(labware: labware)
end
end
10 changes: 5 additions & 5 deletions app/controllers/plates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ def fail_wells # rubocop:todo Metrics/AbcSize
notice: 'No wells were selected to fail' # rubocop:todo Rails/I18nLocaleTexts
)
else
api.state_change.create!(
user: current_user_uuid,
target: params[:id],
Sequencescape::Api::V2::StateChange.create!(
contents: wells_to_fail,
target_state: 'failed',
customer_accepts_responsibility: params[:customer_accepts_responsibility],
reason: 'Individual Well Failure',
customer_accepts_responsibility: params[:customer_accepts_responsibility]
target_state: 'failed',
target_uuid: params[:id],
user_uuid: current_user_uuid
)
redirect_to(
limber_plate_path(params[:id]),
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/print_jobs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def print_job_params
def find_printer_from_name
# there's bound to be a better way of doing this, so we don't have to
# requery all the printers here to find the right one
printers = api.barcode_printer.all
printers = Sequencescape::Api::V2::BarcodePrinter.all
printers.find { |p| p.name == print_job_params[:printer_name] }
end
end
2 changes: 1 addition & 1 deletion app/controllers/robots_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def update_bed_labware_metadata(bed, robot_barcode)
#
def labware_created_with_robot(labware_barcode, robot_barcode)
LabwareMetadata
.new(api: api, user: current_user_uuid, barcode: labware_barcode)
.new(user_uuid: current_user_uuid, barcode: labware_barcode)
.update!(created_with_robot: robot_barcode)
end

Expand Down
Loading
Loading