diff --git a/app/src/calibration/labware/__tests__/selectors.test.js b/app/src/calibration/labware/__tests__/selectors.test.js index 31f0f725e29..70624887cc4 100644 --- a/app/src/calibration/labware/__tests__/selectors.test.js +++ b/app/src/calibration/labware/__tests__/selectors.test.js @@ -274,5 +274,45 @@ describe('labware calibration selectors', () => { }, ]) }) + + it('does not aggregate labware across differing parents', () => { + getLabware.mockReturnValue([ + ({ + type: wellPlate96Def.parameters.loadName, + definition: wellPlate96Def, + slot: '2', + }: $Shape), + ({ + type: wellPlate96Def.parameters.loadName, + definition: wellPlate96Def, + slot: '3', + }: $Shape), + ]) + + getModulesBySlot.mockImplementation(calledState => { + return { + '3': { + model: 'magneticModuleV1', + slot: '3', + _id: 1945365648, + }, + } + }) + + expect(Selectors.getProtocolLabwareList(state, robotName)).toEqual([ + { + displayName: wellPlate96Def.metadata.displayName, + parentDisplayName: null, + quantity: 1, + calibration: null, + }, + { + displayName: wellPlate96Def.metadata.displayName, + parentDisplayName: 'Magnetic Module GEN1', + quantity: 1, + calibration: null, + }, + ]) + }) }) }) diff --git a/app/src/calibration/labware/selectors.js b/app/src/calibration/labware/selectors.js index 843b6eba6b5..28647360546 100644 --- a/app/src/calibration/labware/selectors.js +++ b/app/src/calibration/labware/selectors.js @@ -70,16 +70,25 @@ export const getProtocolLabwareList: ( const { definition: def, loadName, namespace, version, parent } = lw const displayName = def ? getLabwareDisplayName(def) : loadName const parentDisplayName = parent ? getModuleDisplayName(parent) : null - const matchesLabwareIdentity = target => + const matchesLabwareIdentityForQuantity = target => target.loadName === loadName && target.namespace === namespace && target.version === version && - (parent === null || target.parent === parent) + target.parent === parent + + const quantity = baseLabwareList.filter(matchesLabwareIdentityForQuantity) + .length - const quantity = baseLabwareList.filter(matchesLabwareIdentity).length + const matchesLabwareIdentityForCalibration = target => + target.loadName === loadName && + target.namespace === namespace && + target.version === version && + (parent === null || target.parent === parent) const calData = calibrations - .filter(({ attributes }) => matchesLabwareIdentity(attributes)) + .filter(({ attributes }) => + matchesLabwareIdentityForCalibration(attributes) + ) .map(({ attributes }) => { const calVector = attributes.calibrationData.offset.value.map(n => round(n, 1)