Skip to content

Commit

Permalink
fix(app): unblock 96-Channel detach flow and calibration error flow (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
smb2268 authored May 22, 2023
1 parent a112786 commit bc15411
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 73 deletions.
2 changes: 2 additions & 0 deletions app/src/organisms/PipetteWizardFlows/AttachProbe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ export const AttachProbe = (props: AttachProbeProps): JSX.Element | null => {
proceed={proceed}
isOnDevice={isOnDevice}
errorMessage={errorMessage}
chainRunCommands={chainRunCommands}
mount={mount}
/>
) : (
<GenericWizardTile
Expand Down
28 changes: 25 additions & 3 deletions app/src/organisms/PipetteWizardFlows/CalibrationErrorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,40 @@ import { useTranslation } from 'react-i18next'
import { COLORS, PrimaryButton } from '@opentrons/components'
import { SmallButton } from '../../atoms/buttons'
import { SimpleWizardBody } from '../../molecules/SimpleWizardBody'
import type { CreateCommand, PipetteMount } from '@opentrons/shared-data'

interface CalibrationErrorModalProps {
proceed: () => void
isOnDevice: boolean | null
errorMessage: string
chainRunCommands: (
commands: CreateCommand[],
continuePastCommandFailure: boolean
) => Promise<any>
mount: PipetteMount
}

export function CalibrationErrorModal(
props: CalibrationErrorModalProps
): JSX.Element {
const { proceed, isOnDevice, errorMessage } = props
const { proceed, isOnDevice, errorMessage, chainRunCommands, mount } = props
const { t, i18n } = useTranslation(['pipette_wizard_flows', 'shared'])
const handleProceed = (): void => {
chainRunCommands(
[
{
// @ts-expect-error calibration type not yet supported
commandType: 'calibration/moveToMaintenancePosition' as const,
params: {
mount: mount,
},
},
],
false
).then(() => {
proceed()
})
}
return (
<SimpleWizardBody
iconColor={COLORS.errorEnabled}
Expand All @@ -24,12 +46,12 @@ export function CalibrationErrorModal(
>
{isOnDevice ? (
<SmallButton
onClick={proceed}
onClick={handleProceed}
buttonText={i18n.format(t('next'), 'capitalize')}
buttonType="primary"
/>
) : (
<PrimaryButton onClick={proceed}>
<PrimaryButton onClick={handleProceed}>
{i18n.format(t('next'), 'capitalize')}
</PrimaryButton>
)}
Expand Down
14 changes: 2 additions & 12 deletions app/src/organisms/PipetteWizardFlows/Carriage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
PrimaryButton,
SecondaryButton,
} from '@opentrons/components'
import { SINGLE_MOUNT_PIPETTES, LEFT } from '@opentrons/shared-data'
import { LEFT } from '@opentrons/shared-data'
import { StyledText } from '../../atoms/text'
import { SmallButton } from '../../atoms/buttons'
import { GenericWizardTile } from '../../molecules/GenericWizardTile'
Expand All @@ -19,14 +19,7 @@ import { BODY_STYLE, FLOWS } from './constants'
import type { PipetteWizardStepProps } from './types'

export const Carriage = (props: PipetteWizardStepProps): JSX.Element | null => {
const {
goBack,
proceed,
flowType,
selectedPipette,
chainRunCommands,
isOnDevice,
} = props
const { goBack, proceed, flowType, chainRunCommands, isOnDevice } = props
const { t, i18n } = useTranslation(['pipette_wizard_flows', 'shared'])
const [errorMessage, setErrorMessage] = React.useState<boolean>(false)
const [numberOfTryAgains, setNumberOfTryAgains] = React.useState<number>(0)
Expand Down Expand Up @@ -54,9 +47,6 @@ export const Carriage = (props: PipetteWizardStepProps): JSX.Element | null => {
setErrorMessage(true)
})
}
// this should never happen but to be safe
if (selectedPipette === SINGLE_MOUNT_PIPETTES || flowType === FLOWS.CALIBRATE)
return null

return errorMessage ? (
<SimpleWizardBody
Expand Down
7 changes: 1 addition & 6 deletions app/src/organisms/PipetteWizardFlows/MountingPlate.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react'
import { Trans, useTranslation } from 'react-i18next'
import { RIGHT, SINGLE_MOUNT_PIPETTES } from '@opentrons/shared-data'
import { RIGHT } from '@opentrons/shared-data'
import { SPACING } from '@opentrons/components'
import { StyledText } from '../../atoms/text'
import { GenericWizardTile } from '../../molecules/GenericWizardTile'
Expand All @@ -15,16 +15,11 @@ export const MountingPlate = (
goBack,
proceed,
flowType,
selectedPipette,
chainRunCommands,
setShowErrorMessage,
} = props
const { t, i18n } = useTranslation(['pipette_wizard_flows', 'shared'])

// this should never happen but to be safe
if (selectedPipette === SINGLE_MOUNT_PIPETTES || flowType === FLOWS.CALIBRATE)
return null

const handleDetachMountingPlate = (): void => {
chainRunCommands(
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,27 @@ describe('CalibrationErrorModal', () => {
proceed: jest.fn(),
errorMessage: 'error shmerror',
isOnDevice: false,
chainRunCommands: jest.fn(() => Promise.resolve()),
mount: 'left',
}
const { getByText, getByRole } = render(props)
getByText('Pipette calibration failed')
getByText('error shmerror')
getByRole('button', { name: 'Next' }).click()
expect(props.proceed).toHaveBeenCalled()
expect(props.chainRunCommands).toHaveBeenCalled()
})
it('renders the on device button with correct text', () => {
props = {
proceed: jest.fn(),
errorMessage: 'error shmerror',
isOnDevice: true,
chainRunCommands: jest.fn(() => Promise.resolve()),
mount: 'left',
}
const { getByText, getByLabelText } = render(props)
getByText('Pipette calibration failed')
getByText('error shmerror')
getByLabelText('SmallButton_primary').click()
expect(props.proceed).toHaveBeenCalled()
expect(props.chainRunCommands).toHaveBeenCalled()
})
})
22 changes: 1 addition & 21 deletions app/src/organisms/PipetteWizardFlows/__tests__/Carriage.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import * as React from 'react'
import { fireEvent, screen, waitFor } from '@testing-library/react'
import { renderWithProviders } from '@opentrons/components'
import {
LEFT,
NINETY_SIX_CHANNEL,
SINGLE_MOUNT_PIPETTES,
} from '@opentrons/shared-data'
import { LEFT, NINETY_SIX_CHANNEL } from '@opentrons/shared-data'
import { i18n } from '../../../i18n'
import { mockAttachedPipetteInformation } from '../../../redux/pipettes/__fixtures__'
import { RUN_ID_1 } from '../../RunTimeControl/__fixtures__'
Expand Down Expand Up @@ -71,22 +67,6 @@ describe('Carriage', () => {
getByLabelText('back').click()
expect(props.goBack).toHaveBeenCalled()
})
it('renders null if a single mount pipette is attached', () => {
props = {
...props,
selectedPipette: SINGLE_MOUNT_PIPETTES,
}
const { container } = render(props)
expect(container.firstChild).toBeNull()
})
it('renders null if flow is calibrate is attached', () => {
props = {
...props,
flowType: FLOWS.CALIBRATE,
}
const { container } = render(props)
expect(container.firstChild).toBeNull()
})
it('clicking on continue button executes the commands correctly', async () => {
const { getByRole } = render(props)
const contBtn = getByRole('button', { name: 'Continue' })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import * as React from 'react'
import { fireEvent, waitFor } from '@testing-library/react'
import { renderWithProviders } from '@opentrons/components'
import {
LEFT,
NINETY_SIX_CHANNEL,
RIGHT,
SINGLE_MOUNT_PIPETTES,
} from '@opentrons/shared-data'
import { LEFT, NINETY_SIX_CHANNEL, RIGHT } from '@opentrons/shared-data'
import { i18n } from '../../../i18n'
import { mockAttachedPipetteInformation } from '../../../redux/pipettes/__fixtures__'
import { RUN_ID_1 } from '../../RunTimeControl/__fixtures__'
Expand Down Expand Up @@ -85,21 +80,4 @@ describe('MountingPlate', () => {
fireEvent.click(backBtn)
expect(props.goBack).toHaveBeenCalled()
})
it('renders null if a single mount pipette is attached', () => {
props = {
...props,
selectedPipette: SINGLE_MOUNT_PIPETTES,
}
const { container } = render(props)
expect(container.firstChild).toBeNull()
})

it('renders null if flow is calibrate is attached', () => {
props = {
...props,
flowType: FLOWS.CALIBRATE,
}
const { container } = render(props)
expect(container.firstChild).toBeNull()
})
})
15 changes: 9 additions & 6 deletions app/src/organisms/PipetteWizardFlows/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,21 @@ export const PipetteWizardFlows = (

const { deleteMaintenanceRun } = useDeleteMaintenanceRunMutation({
onSuccess: () => handleClose(),
onError: () => handleClose(),
})

const handleCleanUpAndClose = (): void => {
setIsExiting(true)
if (maintenanceRunId == null) handleClose()
else {
chainRunCommands(
[{ commandType: 'home' as const, params: {} }],
true
).then(() => {
deleteMaintenanceRun(maintenanceRunId)
})
chainRunCommands([{ commandType: 'home' as const, params: {} }], false)
.then(() => {
deleteMaintenanceRun(maintenanceRunId)
})
.catch(error => {
console.error(error)
handleClose()
})
}
}
const {
Expand Down

0 comments on commit bc15411

Please sign in to comment.