Skip to content

Commit

Permalink
refactor(app): improve error recovery error fallback for drop tip wiz…
Browse files Browse the repository at this point in the history
…ard errors
  • Loading branch information
mjhuff committed Nov 13, 2024
1 parent 50c314c commit 6f0c618
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,15 @@ describe('getInitialRouteAndStep', () => {
expect(initialRoute).toBe(DT_ROUTES.DROP_TIP)
expect(initialStep).toBe(DT_ROUTES.DROP_TIP[2])
})

it('should return the overridden route and first step when fixitUtils.routeOverride.route is provided but routeOverride.step is not provided', () => {
const fixitUtils = {
routeOverride: { route: DT_ROUTES.DROP_TIP, step: null },
} as any

const [initialRoute, initialStep] = getInitialRouteAndStep(fixitUtils)

expect(initialRoute).toBe(DT_ROUTES.DROP_TIP)
expect(initialStep).toBe(DT_ROUTES.DROP_TIP[0])
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,10 @@ export function getInitialRouteAndStep(
): [DropTipFlowsRoute, DropTipFlowsStep] {
const routeOverride = fixitUtils?.routeOverride
const initialRoute = routeOverride?.route ?? DT_ROUTES.BEFORE_BEGINNING
const initialStep = routeOverride?.step ?? BEFORE_BEGINNING_STEPS[0]
const initialStep =
routeOverride?.step ??
routeOverride?.route?.[0] ??
BEFORE_BEGINNING_STEPS[0]

return [initialRoute, initialStep]
}
4 changes: 4 additions & 0 deletions app/src/organisms/ErrorRecoveryFlows/RecoveryError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export function RecoveryDropTipFlowErrors({
routeUpdateActions,
getRecoveryOptionCopy,
errorKind,
subMapUtils,
}: RecoveryContentProps): JSX.Element {
const { t } = useTranslation('error_recovery')
const { step } = recoveryMap
Expand All @@ -108,6 +109,9 @@ export function RecoveryDropTipFlowErrors({
errorKind
)

// Whenever there is an error during drop tip wizard, reset the submap so properly re-entry routing occurs.
subMapUtils.updateSubMap(null)

const buildTitle = (): string => {
switch (step) {
case ERROR_WHILE_RECOVERING.STEPS.DROP_TIP_GENERAL_ERROR:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ describe('RecoveryError', () => {
let getRecoverOptionCopyMock: Mock
let handleMotionRoutingMock: Mock
let homePipetteZAxesMock: Mock
let updateSubMapMock: Mock

beforeEach(() => {
proceedToRouteAndStepMock = vi.fn()
getRecoverOptionCopyMock = vi.fn()
handleMotionRoutingMock = vi.fn().mockResolvedValue(undefined)
homePipetteZAxesMock = vi.fn().mockResolvedValue(undefined)
updateSubMapMock = vi.fn()

props = {
...mockRecoveryContentProps,
Expand All @@ -48,6 +50,7 @@ describe('RecoveryError', () => {
route: ERROR_WHILE_RECOVERING.ROUTE,
step: ERROR_WHILE_RECOVERING.STEPS.RECOVERY_ACTION_FAILED,
},
subMapUtils: { subMap: null, updateSubMap: updateSubMapMock },
}

getRecoverOptionCopyMock.mockReturnValue('Retry step')
Expand Down Expand Up @@ -95,7 +98,7 @@ describe('RecoveryError', () => {
expect(screen.queryAllByText('Continue to drop tip')[0]).toBeInTheDocument()
})

it(`renders RecoveryDropTipFlowErrors when step is ${ERROR_WHILE_RECOVERING.STEPS.DROP_TIP_TIP_DROP_FAILED}`, () => {
it(`renders RecoveryDropTipFlowErrors when step is ${ERROR_WHILE_RECOVERING.STEPS.DROP_TIP_TIP_DROP_FAILED} and resets the submap`, () => {
props.recoveryMap.step =
RECOVERY_MAP.ERROR_WHILE_RECOVERING.STEPS.DROP_TIP_TIP_DROP_FAILED
render(props)
Expand All @@ -107,6 +110,7 @@ describe('RecoveryError', () => {
)[0]
).toBeInTheDocument()
expect(screen.queryAllByText('Return to menu')[0]).toBeInTheDocument()
expect(updateSubMapMock).toHaveBeenCalledWith(null)
})

it(`calls proceedToRouteAndStep with ${RECOVERY_MAP.OPTION_SELECTION.ROUTE} when the "Return to menu" button is clicked in RecoveryDropTipFlowErrors with step ${ERROR_WHILE_RECOVERING.STEPS.DROP_TIP_GENERAL_ERROR}`, () => {
Expand Down

0 comments on commit 6f0c618

Please sign in to comment.