Skip to content

Commit

Permalink
fix(app): fix tiprack in tip probe instructions when tipracks are sha…
Browse files Browse the repository at this point in the history
…red (#5319)

Closes #5311
  • Loading branch information
mcous authored Mar 30, 2020
1 parent 3c7fcc8 commit 7d5f4ab
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 10 deletions.
9 changes: 8 additions & 1 deletion app/src/robot/api-client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,12 +584,19 @@ export function client(dispatch) {
})
.map(t => t._id)

// ensure IDs are actually present in containers list
// RPC API as of 3.16 may return bogus tipracks in pipette tipracks list
const tipRacks = union(
tipRacksFromInstrument,
tipRacksFromContainers
).filter(id => containers.some(c => c._id === id))

update.pipettesByMount[mount] = {
_id,
mount,
name,
channels,
tipRacks: union(tipRacksFromInstrument, tipRacksFromContainers),
tipRacks,
requestedAs: requested_as,
}
}
Expand Down
20 changes: 16 additions & 4 deletions app/src/robot/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,20 @@ export const getTipracksByMount: (
state: State
) => TiprackByMountMap = createSelector(
getTipracks,
tipracks => ({
left: tipracks.find(tr => tr.calibratorMount === 'left') || null,
right: tipracks.find(tr => tr.calibratorMount === 'right') || null,
})
getPipettesByMount,
(tipracks, pipettesMap) => {
return PIPETTE_MOUNTS.reduce<TiprackByMountMap>(
(tiprackMap, mount) => {
const byCalibrator = tipracks.find(tr => tr.calibratorMount === mount)
const byTiprackList = tipracks.find(tr =>
(pipettesMap[mount]?.tipRacks ?? []).includes(tr._id)
)

tiprackMap[mount] = byCalibrator ?? byTiprackList ?? null

return tiprackMap
},
{ left: null, right: null }
)
}
)
12 changes: 8 additions & 4 deletions app/src/robot/test/api-client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ describe('api client', () => {
},
]

session.containers = [{ _id: 3 }, { _id: 4 }, { _id: 5 }]

return sendConnect().then(() =>
expect(dispatch).toHaveBeenCalledWith(expected)
)
Expand Down Expand Up @@ -555,15 +557,17 @@ describe('api client', () => {
mount: 'right',
name: 'p50',
channels: 8,
tip_racks: [],
// guard against bogus tipracks in this array, which RPC API has been
// observed doing as of 3.16
tip_racks: [{ _id: 888 }],
requested_as: 'foo',
},
{
_id: 123,
mount: 'left',
name: 'p200',
channels: 1,
tip_racks: [],
tip_racks: [{ _id: 999 }],
requested_as: 'bar',
},
]
Expand All @@ -581,9 +585,9 @@ describe('api client', () => {
},
]

return sendConnect().then(() =>
return sendConnect().then(() => {
expect(dispatch).toHaveBeenCalledWith(expected)
)
})
})

it('maps api modules to modules by slot', () => {
Expand Down
61 changes: 60 additions & 1 deletion app/src/robot/test/selectors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ describe('robot selectors', () => {
})
})

it('getTipracksByMount', () => {
it('returns tipracks by calibratorMount with getTipracksByMount', () => {
expect(getTipracksByMount(state)).toEqual({
left: {
slot: '2',
Expand All @@ -766,6 +766,65 @@ describe('robot selectors', () => {
},
})
})

it('uses tiprack lists from pipettes in getTipracksByMount if no calibratorMount', () => {
state = makeState({
session: {
labwareBySlot: {
1: {
_id: 1,
slot: '1',
type: 's',
isTiprack: true,
calibratorMount: 'right',
},
2: {
_id: 2,
slot: '2',
type: 'm',
isTiprack: true,
calibratorMount: 'right',
},
},
pipettesByMount: {
left: { name: 'p200', mount: 'left', tipRacks: [2] },
right: { name: 'p50', mount: 'right', tipRacks: [1, 2] },
},
},
calibration: {
labwareBySlot: {},
confirmedBySlot: {},
calibrationRequest: { type: '', inProgress: false, error: null },
probedByMount: {},
tipOnByMount: {},
},
})

expect(getTipracksByMount(state)).toEqual({
left: {
_id: 2,
slot: '2',
type: 'm',
isTiprack: true,
isMoving: false,
calibration: 'unconfirmed',
confirmed: false,
calibratorMount: 'right',
definition: null,
},
right: {
_id: 1,
slot: '1',
type: 's',
isTiprack: true,
isMoving: false,
calibration: 'unconfirmed',
confirmed: false,
calibratorMount: 'right',
definition: null,
},
})
})
})

it('getDeckPopulated', () => {
Expand Down

0 comments on commit 7d5f4ab

Please sign in to comment.