Skip to content

Commit

Permalink
nicer command errors (and test cleanup)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjhuff committed Jan 15, 2025
1 parent da584ad commit 3ee2308
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
useUnmatchedModulesForProtocol,
} from '/app/resources/runs'
import { useRobotType } from '/app/redux-resources/robots'
import { useLPCFlows } from '/app/organisms/LabwarePositionCheck'

import type { Mock } from 'vitest'

Expand All @@ -34,6 +35,7 @@ vi.mock('/app/redux/config')
vi.mock('../../../hooks/useLPCSuccessToast')
vi.mock('@opentrons/react-api-client')
vi.mock('/app/resources/runs')
vi.mock('/app/organisms/LabwarePositionCheck')

const DISABLED_REASON = 'MOCK_DISABLED_REASON'
const ROBOT_NAME = 'otie'
Expand Down Expand Up @@ -106,6 +108,7 @@ describe('SetupLabwarePositionCheck', () => {
vi.mocked(useProtocolAnalysisAsDocumentQuery).mockReturnValue({
data: null,
} as any)
vi.mocked(useLPCFlows).mockReturnValue({ launchLPC: mockLaunchLPC } as any)
})

afterEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ export function useHandlePrepModules({
prepCommands.length > 0
) {
return chainLPCCommands(prepCommands, false)
} else {
return Promise.resolve([])
}
}

return Promise.reject(
new Error('Cannot prep modules during unsupported step.')
new Error(`Cannot prep modules during unsupported step: ${step?.section}`)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function useHandleValidMoveToMaintenancePosition({
} else {
return Promise.reject(
new Error(
'Does not move to maintenance position if step is not a probe step.'
`Does not move to maintenance position if step is not a probe step. Step: ${step?.section}`
)
)
}
Expand Down
10 changes: 8 additions & 2 deletions app/src/organisms/LabwarePositionCheck/steps/CheckItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Trans, useTranslation } from 'react-i18next'

import { DIRECTION_COLUMN, Flex, LegacyStyledText } from '@opentrons/components'

import { NAV_STEPS } from '/app/organisms/LabwarePositionCheck/constants'
import { FLEX_ROBOT_TYPE } from '@opentrons/shared-data'
import { getLabwareDisplayLocation } from '/app/local-resources/labware'
import { UnorderedList } from '/app/molecules/UnorderedList'
Expand Down Expand Up @@ -101,8 +102,13 @@ export function CheckItem(
})
)
})
.then(() => handleCheckItemsPrepModules(steps.next))
.then(() => handleValidMoveToMaintenancePosition(steps.next))
.then(() => {
if (state.steps.next?.section === NAV_STEPS.CHECK_POSITIONS) {
return handleCheckItemsPrepModules(steps.next)
} else {
return handleValidMoveToMaintenancePosition(steps.next)
}
})
.finally(() => toggleRobotMoving(false))
}

Expand Down
2 changes: 2 additions & 0 deletions app/src/organisms/LegacyLabwarePositionCheck/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ interface LabwarePositionCheckModalProps {
// the component's dependencies (like useLabwarePositionCheck). If we wrapped the contents of LabwarePositionCheckComponent
// in an ErrorBoundary as part of its return value (render), an error could occur before this point, meaning the error boundary
// would never get invoked

// LegacyFlows are utilized by the OT-2, and should never actually be utilized by the Flex despite offering Flex support.
export const LegacyLabwarePositionCheck = (
props: LabwarePositionCheckModalProps
): JSX.Element => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import {
import { mockConnectableRobot } from '/app/redux/discovery/__fixtures__'
import { mockRunTimeParameterData } from '/app/organisms/ODD/ProtocolSetup/__fixtures__'
import { useScrollPosition } from '/app/local-resources/dom-utils'
import { useLPCFlows } from '/app/organisms/LabwarePositionCheck'

import type { UseQueryResult } from 'react-query'
import type * as SharedData from '@opentrons/shared-data'
Expand Down Expand Up @@ -115,6 +116,7 @@ vi.mock('/app/redux-resources/analytics')
vi.mock('/app/redux-resources/robots')
vi.mock('/app/resources/modules')
vi.mock('/app/local-resources/dom-utils')
vi.mock('/app/organisms/LabwarePositionCheck')

const render = (path = '/') => {
return renderWithProviders(
Expand Down Expand Up @@ -328,6 +330,7 @@ describe('ProtocolSetup', () => {
isScrolled: false,
scrollRef: {} as any,
})
vi.mocked(useLPCFlows).mockReturnValue({ launchLPC: mockLaunchLPC } as any)
})

it('should render text, image, and buttons', () => {
Expand Down

0 comments on commit 3ee2308

Please sign in to comment.