Skip to content

Commit

Permalink
fix(protocol-designer): allow wasteChute selection when staging area …
Browse files Browse the repository at this point in the history
…in d3 (#15314)

closes RQA-2790
  • Loading branch information
jerader authored Jun 3, 2024
1 parent 1c76569 commit 203c1e4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,21 @@ describe('getNumSlotsAvailable', () => {
const result = getNumSlotsAvailable(null, mockAdditionalEquipment)
expect(result).toBe(1)
})
it('shoult return 1 when it is for the waste chute and all slots are occupied with the staging area in slot d3', () => {
const mockAdditionalEquipment: AdditionalEquipment[] = [
'trashBin',
'trashBin',
'stagingArea_cutoutA3',
'stagingArea_cutoutB3',
'stagingArea_cutoutC3',
'stagingArea_cutoutD3',
'trashBin',
'gripper',
'trashBin',
]
const result = getNumSlotsAvailable(null, mockAdditionalEquipment, true)
expect(result).toBe(1)
})
it('should return 8 even when there is a magnetic block', () => {
const mockModules = {
0: {
Expand Down
13 changes: 11 additions & 2 deletions protocol-designer/src/components/modals/CreateFileWizard/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ const TOTAL_MODULE_SLOTS = 8

export const getNumSlotsAvailable = (
modules: FormState['modules'],
additionalEquipment: FormState['additionalEquipment']
additionalEquipment: FormState['additionalEquipment'],
// special-casing the wasteChute available slots when there is a staging area in slot 3
isWasteChute?: boolean
): number => {
const additionalEquipmentLength = additionalEquipment.length
const hasTC = Object.values(modules || {}).some(
Expand Down Expand Up @@ -99,6 +101,9 @@ export const getNumSlotsAvailable = (
if (hasWasteChute && isStagingAreaInD3) {
filteredAdditionalEquipmentLength = filteredAdditionalEquipmentLength - 1
}
if (isWasteChute && isStagingAreaInD3) {
filteredAdditionalEquipmentLength = filteredAdditionalEquipmentLength - 1
}
if (hasGripper) {
filteredAdditionalEquipmentLength = filteredAdditionalEquipmentLength - 1
}
Expand Down Expand Up @@ -132,7 +137,11 @@ export const getTrashOptionDisabled = (
): boolean => {
const { additionalEquipment, modules, trashType } = props
const hasNoSlotsAvailable =
getNumSlotsAvailable(modules, additionalEquipment) === 0
getNumSlotsAvailable(
modules,
additionalEquipment,
trashType === 'wasteChute'
) === 0
return hasNoSlotsAvailable && !additionalEquipment.includes(trashType)
}

Expand Down

0 comments on commit 203c1e4

Please sign in to comment.