Skip to content

Commit

Permalink
fix(app): fix gantry not homing when no labware in gripper jaws durin…
Browse files Browse the repository at this point in the history
…g Error Recovery
  • Loading branch information
mjhuff committed Jan 7, 2025
1 parent c45938d commit fc69449
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ export const HOLDING_LABWARE_OPTIONS: HoldingLabwareOption[] = [
export function GripperIsHoldingLabware({
routeUpdateActions,
currentRecoveryOptionUtils,
recoveryCommands,
}: RecoveryContentProps): JSX.Element {
const {
proceedNextStep,
proceedToRouteAndStep,
goBackPrevStep,
handleMotionRouting,
} = routeUpdateActions
const { homeExceptPlungers } = recoveryCommands
const { selectedRecoveryOption } = currentRecoveryOptionUtils
const {
MANUAL_MOVE_AND_SKIP,
Expand All @@ -48,24 +51,29 @@ export function GripperIsHoldingLabware({
const { t } = useTranslation(['error_recovery', 'shared'])

const handleNoOption = (): void => {
switch (selectedRecoveryOption) {
case MANUAL_MOVE_AND_SKIP.ROUTE:
void proceedToRouteAndStep(
MANUAL_MOVE_AND_SKIP.ROUTE,
MANUAL_MOVE_AND_SKIP.STEPS.MANUAL_MOVE
)
break
case MANUAL_REPLACE_AND_RETRY.ROUTE:
void proceedToRouteAndStep(
MANUAL_REPLACE_AND_RETRY.ROUTE,
MANUAL_REPLACE_AND_RETRY.STEPS.MANUAL_REPLACE
)
break
default: {
console.error('Unexpected recovery option for gripper routing.')
void proceedToRouteAndStep(OPTION_SELECTION.ROUTE)
}
}
// The "yes" option also contains a home, but it occurs later in the control flow,
// after the user has extricated the labware from the gripper jaws.
void handleMotionRouting(true)
.then(() => homeExceptPlungers())
.then(() => {
switch (selectedRecoveryOption) {
case MANUAL_MOVE_AND_SKIP.ROUTE:
return proceedToRouteAndStep(
MANUAL_MOVE_AND_SKIP.ROUTE,
MANUAL_MOVE_AND_SKIP.STEPS.MANUAL_MOVE
)
case MANUAL_REPLACE_AND_RETRY.ROUTE:
return proceedToRouteAndStep(
MANUAL_REPLACE_AND_RETRY.ROUTE,
MANUAL_REPLACE_AND_RETRY.STEPS.MANUAL_REPLACE
)
default: {
console.error('Unexpected recovery option for gripper routing.')
return proceedToRouteAndStep(OPTION_SELECTION.ROUTE)
}
}
})
.finally(() => handleMotionRouting(false))
}

const primaryOnClick = (): void => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,25 @@ const render = (props: ComponentProps<typeof GripperIsHoldingLabware>) => {

let mockProceedToRouteAndStep: Mock
let mockProceedNextStep: Mock
let mockHandleMotionRouting: Mock
let mockHomeExceptPlungers: Mock

describe('GripperIsHoldingLabware', () => {
let props: ComponentProps<typeof GripperIsHoldingLabware>
beforeEach(() => {
mockProceedToRouteAndStep = vi.fn(() => Promise.resolve())
mockProceedNextStep = vi.fn(() => Promise.resolve())
mockHandleMotionRouting = vi.fn(() => Promise.resolve())
mockHomeExceptPlungers = vi.fn(() => Promise.resolve())

props = {
...mockRecoveryContentProps,
routeUpdateActions: {
proceedToRouteAndStep: mockProceedToRouteAndStep,
proceedNextStep: mockProceedNextStep,
handleMotionRouting: mockHandleMotionRouting,
} as any,
recoveryCommands: { homeExceptPlungers: mockHomeExceptPlungers } as any,
}
})

Expand Down Expand Up @@ -82,12 +88,24 @@ describe('GripperIsHoldingLabware', () => {
fireEvent.click(screen.getAllByLabelText('No')[0])
clickButtonLabeled('Continue')

await waitFor(() => {
expect(mockHandleMotionRouting).toHaveBeenCalledWith(true)
})

await waitFor(() => {
expect(mockHomeExceptPlungers).toHaveBeenCalled()
})

await waitFor(() => {
expect(mockProceedToRouteAndStep).toHaveBeenCalledWith(
RECOVERY_MAP.MANUAL_MOVE_AND_SKIP.ROUTE,
RECOVERY_MAP.MANUAL_MOVE_AND_SKIP.STEPS.MANUAL_MOVE
)
})

await waitFor(() => {
expect(mockHandleMotionRouting).toHaveBeenCalledWith(false)
})
})

it(`proceeds to the correct step when the no option is clicked for ${RECOVERY_MAP.MANUAL_REPLACE_AND_RETRY.ROUTE}`, async () => {
Expand Down

0 comments on commit fc69449

Please sign in to comment.