1
1
import { vi , it , describe , expect } from 'vitest'
2
2
3
3
import { ANY_LOCATION } from '@opentrons/api-client'
4
- import { C2_ADDRESSABLE_AREA , getLabwareDefURI } from '@opentrons/shared-data'
4
+ import {
5
+ C3_ADDRESSABLE_AREA ,
6
+ C2_ADDRESSABLE_AREA ,
7
+ getLabwareDefURI ,
8
+ } from '@opentrons/shared-data'
5
9
6
10
import { getDefaultOffsetDetailsForLabware } from '../getDefaultOffsetForLabware'
7
11
import { OFFSET_KIND_DEFAULT } from '/app/redux/protocol-runs'
@@ -25,7 +29,27 @@ describe('getDefaultOffsetDetailsForLabware', () => {
25
29
const ADAPTER_URI = 'opentrons/adapter-1'
26
30
27
31
const MOCK_LW_LOC_COMBOS = [
28
- { definitionUri : LABWARE_URI , labwareId : LABWARE_ID } ,
32
+ {
33
+ definitionUri : LABWARE_URI ,
34
+ labwareId : LABWARE_ID ,
35
+ addressableAreaName : 'A1' ,
36
+ closestBeneathModuleId : null ,
37
+ } ,
38
+ ]
39
+
40
+ const MOCK_LW_LOC_COMBOS_WITH_MODULE = [
41
+ {
42
+ definitionUri : LABWARE_URI ,
43
+ labwareId : LABWARE_ID ,
44
+ addressableAreaName : 'A1' ,
45
+ closestBeneathModuleId : 'module-123' ,
46
+ } ,
47
+ {
48
+ definitionUri : 'other-labware' ,
49
+ labwareId : 'other-labware-id' ,
50
+ addressableAreaName : 'B2' ,
51
+ closestBeneathModuleId : null ,
52
+ } ,
29
53
]
30
54
31
55
const MOCK_OFFSET : StoredLabwareOffset = {
@@ -74,7 +98,7 @@ describe('getDefaultOffsetDetailsForLabware', () => {
74
98
modules : [ ] ,
75
99
}
76
100
77
- const MOCK_PROTOCOL_DATA_WITH_MODULES = {
101
+ const MOCK_PROTOCOL_DATA_WITH_C2_MODULE = {
78
102
labware : [
79
103
{
80
104
id : ADAPTER_ID ,
@@ -85,9 +109,6 @@ describe('getDefaultOffsetDetailsForLabware', () => {
85
109
{
86
110
location : { slotName : 'C2' } ,
87
111
} ,
88
- {
89
- location : { slotName : 'A1' } ,
90
- } ,
91
112
] ,
92
113
}
93
114
@@ -235,59 +256,61 @@ describe('getDefaultOffsetDetailsForLabware', () => {
235
256
expect ( result . locationDetails . addressableAreaName ) . toBe ( C2_ADDRESSABLE_AREA )
236
257
} )
237
258
238
- it ( 'should use alternative slot when C2 is occupied by a module ' , ( ) => {
259
+ it ( 'should find first location with no module when C2 is occupied' , ( ) => {
239
260
const result = getDefaultOffsetDetailsForLabware ( {
240
261
uri : LABWARE_URI ,
241
- lwLocInfo : MOCK_LW_LOC_COMBOS ,
262
+ lwLocInfo : MOCK_LW_LOC_COMBOS_WITH_MODULE ,
242
263
currentOffsets : [ ] ,
243
264
labwareDefs : [ MOCK_LABWARE_DEF ] ,
244
265
locationSpecificOffsetDetails : [ ] ,
245
- protocolData : MOCK_PROTOCOL_DATA_WITH_MODULES ,
266
+ protocolData : MOCK_PROTOCOL_DATA_WITH_C2_MODULE ,
246
267
} as any )
247
268
248
- expect ( result . locationDetails . addressableAreaName ) . not . toBe (
249
- C2_ADDRESSABLE_AREA
250
- )
251
- expect ( [
252
- 'A2' ,
253
- 'A3' ,
254
- 'B1' ,
255
- 'B2' ,
256
- 'B3' ,
257
- 'C1' ,
258
- 'C3' ,
259
- 'D1' ,
260
- 'D2' ,
261
- 'D3' ,
262
- ] ) . toContain ( result . locationDetails . addressableAreaName )
269
+ expect ( result . locationDetails . addressableAreaName ) . toBe ( 'B2' )
263
270
} )
264
271
265
- it ( 'should fallback to C2 when all slots are occupied' , ( ) => {
266
- const protocolDataWithAllModules = {
267
- labware : [ ] ,
268
- modules : [
269
- { location : { slotName : 'A1' } } ,
270
- { location : { slotName : 'A2' } } ,
271
- { location : { slotName : 'A3' } } ,
272
- { location : { slotName : 'B1' } } ,
273
- { location : { slotName : 'B2' } } ,
274
- { location : { slotName : 'B3' } } ,
275
- { location : { slotName : 'C1' } } ,
276
- { location : { slotName : 'C2' } } ,
277
- { location : { slotName : 'C3' } } ,
278
- { location : { slotName : 'D1' } } ,
279
- { location : { slotName : 'D2' } } ,
280
- { location : { slotName : 'D3' } } ,
281
- ] ,
282
- }
272
+ it ( 'should fallback to C3 when C2 is occupied and no locations without modules are found' , ( ) => {
273
+ const lwLocInfoAllWithModules = [
274
+ {
275
+ definitionUri : LABWARE_URI ,
276
+ labwareId : LABWARE_ID ,
277
+ addressableAreaName : 'A1' as any ,
278
+ closestBeneathModuleId : 'module-1' ,
279
+ } ,
280
+ {
281
+ definitionUri : 'other-labware' ,
282
+ labwareId : 'other-labware-id' ,
283
+ addressableAreaName : 'B2' as any ,
284
+ closestBeneathModuleId : 'module-2' ,
285
+ } ,
286
+ ]
287
+
288
+ const result = getDefaultOffsetDetailsForLabware ( {
289
+ uri : LABWARE_URI ,
290
+ lwLocInfo : lwLocInfoAllWithModules ,
291
+ currentOffsets : [ ] ,
292
+ labwareDefs : [ MOCK_LABWARE_DEF ] ,
293
+ locationSpecificOffsetDetails : [ ] ,
294
+ protocolData : MOCK_PROTOCOL_DATA_WITH_C2_MODULE ,
295
+ } as any )
296
+
297
+ expect ( result . locationDetails . addressableAreaName ) . toBe ( C3_ADDRESSABLE_AREA )
298
+ } )
283
299
300
+ it ( 'should return C2 when C2 is not occupied by modules' , ( ) => {
284
301
const result = getDefaultOffsetDetailsForLabware ( {
285
302
uri : LABWARE_URI ,
286
303
lwLocInfo : MOCK_LW_LOC_COMBOS ,
287
304
currentOffsets : [ ] ,
288
305
labwareDefs : [ MOCK_LABWARE_DEF ] ,
289
306
locationSpecificOffsetDetails : [ ] ,
290
- protocolData : protocolDataWithAllModules ,
307
+ protocolData : {
308
+ labware : [ ] ,
309
+ modules : [
310
+ { location : { slotName : 'A1' } } ,
311
+ { location : { slotName : 'B1' } } ,
312
+ ] ,
313
+ } ,
291
314
} as any )
292
315
293
316
expect ( result . locationDetails . addressableAreaName ) . toBe ( C2_ADDRESSABLE_AREA )
0 commit comments