Skip to content

Commit

Permalink
refactor(protocol-designer): minimize and extend position and tuberac… (
Browse files Browse the repository at this point in the history
#14998)

…k warnings

closes AUTH-370 AUTH-371
  • Loading branch information
jerader authored Apr 25, 2024
1 parent c7bd4bb commit 04e00ad
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ export const TipPositionModal = (
yValue != null &&
(parseInt(yValue) > PERCENT_RANGE_TO_SHOW_WARNING * yMaxWidth ||
parseInt(yValue) < PERCENT_RANGE_TO_SHOW_WARNING * yMinWidth)
const isZValueAtBottom = zValue != null && zValue === '0'

const TipPositionInputField = !isDefault ? (
<Flex flexDirection={DIRECTION_COLUMN} gridGap={SPACING.spacing8}>
Expand Down Expand Up @@ -315,7 +316,8 @@ export const TipPositionModal = (
<p>{t(`tip_position.body.${zSpec?.name}`)}</p>
</div>

{(isXValueNearEdge || isYValueNearEdge) && !isDefault ? (
{(isXValueNearEdge || isYValueNearEdge || isZValueAtBottom) &&
!isDefault ? (
<Flex marginTop={SPACING.spacing8}>
<PDAlert
alertType="warning"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ describe('TipPositionModal', () => {
render(props)
screen.getByText('warning')
screen.getByText(
'The X and/or Y position value is close to edge of the well and might collide with it'
'One or more position offset values are close to the edge of the well and might collide with it'
)
})
it('renders the alert if the x/y position values are too close to the max/min for y value', () => {
props.specs.y.value = -9.7
render(props)
screen.getByText('warning')
screen.getByText(
'The X and/or Y position value is close to edge of the well and might collide with it'
'One or more position offset values are close to the edge of the well and might collide with it'
)
})
it('renders the custom options, captions, and visual', () => {
Expand Down
2 changes: 1 addition & 1 deletion protocol-designer/src/localization/en/modal.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"tip_position": {
"title": "Tip Positioning",
"caption": "between {{min}} and {{max}}",
"warning": "The X and/or Y position value is close to edge of the well and might collide with it",
"warning": "One or more position offset values are close to the edge of the well and might collide with it",
"radio_button": {
"default": "{{defaultMmFromBottom}} mm from the bottom center (default)",
"blowout": "0 mm from the top center (default)",
Expand Down
6 changes: 2 additions & 4 deletions protocol-designer/src/steplist/formLevel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ import {
minDisposalVolume,
minAspirateAirGapVolume,
minDispenseAirGapVolume,
aspirateTipPositionInTube,
dispenseTipPositionInTube,
mixTipPositionInTube,
tipPositionInTube,
} from './warnings'

import { HydratedFormdata, StepType } from '../../form-types'
Expand Down Expand Up @@ -75,8 +74,7 @@ const stepFormHelperMap: Partial<Record<StepType, FormHelpers>> = {
minDisposalVolume,
minAspirateAirGapVolume,
minDispenseAirGapVolume,
aspirateTipPositionInTube,
dispenseTipPositionInTube
tipPositionInTube
),
},
magnet: {
Expand Down
22 changes: 7 additions & 15 deletions protocol-designer/src/steplist/formLevel/test/warnings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import {
belowPipetteMinimumVolume,
minDisposalVolume,
maxDispenseWellVolume,
aspirateTipPositionInTube,
dispenseTipPositionInTube,
tipPositionInTube,
mixTipPositionInTube,
} from '../warnings'
import type { LabwareEntity } from '@opentrons/step-generation'
Expand Down Expand Up @@ -294,26 +293,20 @@ describe('Max dispense well volume', () => {
dispense_mmFromBottom: null,
}
})
it('renders the errors for all 3', () => {
expect(aspirateTipPositionInTube(fields)?.type).toBe(
'ASPIRATE_TIP_POSITIONED_LOW_IN_TUBE'
)
expect(dispenseTipPositionInTube(fields)?.type).toBe(
'DISPENSE_TIP_POSITIONED_LOW_IN_TUBE'
)
it('renders the errors for all 2', () => {
expect(tipPositionInTube(fields)?.type).toBe('TIP_POSITIONED_LOW_IN_TUBE')
expect(mixTipPositionInTube(fields)?.type).toBe(
'MIX_TIP_POSITIONED_LOW_IN_TUBE'
)
})
it('renders null for all 3 when the number has been adjusted', () => {
it('renders null for both when the number has been adjusted', () => {
fields.aspirate_mmFromBottom = 3
fields.dispense_mmFromBottom = 3
fields.mix_mmFromBottom = 3
expect(aspirateTipPositionInTube(fields)).toBe(null)
expect(dispenseTipPositionInTube(fields)).toBe(null)
expect(tipPositionInTube(fields)).toBe(null)
expect(mixTipPositionInTube(fields)).toBe(null)
})
it('renders null for all 3 when the labware is not a tube rack', () => {
it('renders null for both when the labware is not a tube rack', () => {
fields.aspirate_labware = {
def: fixture96Plate as LabwareDefinition2,
id: 'mockId',
Expand All @@ -329,8 +322,7 @@ describe('Max dispense well volume', () => {
id: 'mockId',
labwareDefURI: 'mockURI',
}
expect(aspirateTipPositionInTube(fields)).toBe(null)
expect(dispenseTipPositionInTube(fields)).toBe(null)
expect(tipPositionInTube(fields)).toBe(null)
expect(mixTipPositionInTube(fields)).toBe(null)
})
})
Expand Down
58 changes: 28 additions & 30 deletions protocol-designer/src/steplist/formLevel/warnings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import * as React from 'react'
import { getWellTotalVolume } from '@opentrons/shared-data'
import { KnowledgeBaseLink } from '../../components/KnowledgeBaseLink'
import type { FormError } from './errors'

/*******************
** Warning Messages **
********************/

export type FormWarningType =
| 'ASPIRATE_TIP_POSITIONED_LOW_IN_TUBE'
| 'BELOW_MIN_AIR_GAP_VOLUME'
| 'BELOW_MIN_DISPOSAL_VOLUME'
| 'BELOW_PIPETTE_MINIMUM_VOLUME'
| 'DISPENSE_TIP_POSITIONED_LOW_IN_TUBE'
| 'OVER_MAX_WELL_VOLUME'
| 'MIX_TIP_POSITIONED_LOW_IN_TUBE'
| 'TIP_POSITIONED_LOW_IN_TUBE'

export type FormWarning = FormError & {
type: FormWarningType
Expand Down Expand Up @@ -59,18 +59,11 @@ const belowMinDisposalVolumeWarning = (min: number): FormWarning => ({
dependentFields: ['disposalVolume_volume', 'pipette'],
})

const aspirateTipPositionedLowInTube = (): FormWarning => ({
type: 'ASPIRATE_TIP_POSITIONED_LOW_IN_TUBE',
const tipPositionedLowInTube = (): FormWarning => ({
type: 'TIP_POSITIONED_LOW_IN_TUBE',
title:
'The default aspirate height is 1mm from the bottom of the well, which could cause liquid overflow or pipette damage. Edit tip position in advanced settings.',
dependentFields: ['aspirate_labware'],
})

const dispenseTipPositionedLowInTube = (): FormWarning => ({
type: 'DISPENSE_TIP_POSITIONED_LOW_IN_TUBE',
title:
'The default dispense height is 0.5mm from the bottom of the well, which could cause liquid overflow or pipette damage. Edit tip position in advanced settings.',
dependentFields: ['dispense_labware'],
'A tuberack has an aspirate and dispense default height at 1mm and 0.5mm from the bottom of the well, which could cause liquid overflow or pipette damage. Edit tip position in advanced settings.',
dependentFields: ['aspirate_labware', 'dispense_labware'],
})

const mixTipPositionedLowInTube = (): FormWarning => ({
Expand All @@ -88,34 +81,39 @@ export type WarningChecker = (val: unknown) => FormWarning | null
// TODO: real HydratedFormData type
export type HydratedFormData = any

export const aspirateTipPositionInTube = (
export const tipPositionInTube = (
fields: HydratedFormData
): FormWarning | null => {
const { aspirate_labware, aspirate_mmFromBottom } = fields
let isTubeRack: boolean = false
const {
aspirate_labware,
aspirate_mmFromBottom,
dispense_labware,
dispense_mmFromBottom,
} = fields
let isAspirateTubeRack: boolean = false
let isDispenseTubeRack: boolean = false
if (aspirate_labware != null) {
isTubeRack = aspirate_labware.def.metadata.displayCategory === 'tubeRack'
isAspirateTubeRack =
aspirate_labware.def.metadata.displayCategory === 'tubeRack'
}
return isTubeRack && aspirate_mmFromBottom === null
? aspirateTipPositionedLowInTube()
: null
}
export const dispenseTipPositionInTube = (
fields: HydratedFormData
): FormWarning | null => {
const { dispense_labware, dispense_mmFromBottom } = fields
let isTubeRack: boolean = false
if (dispense_labware != null) {
isTubeRack =
isDispenseTubeRack =
// checking that the dispense labware is a labware and not a trash/waste chute
'def' in dispense_labware
? dispense_labware.def.metadata.displayCategory === 'tubeRack'
: false
}
return isTubeRack && dispense_mmFromBottom === null
? dispenseTipPositionedLowInTube()
: null

if (
(isAspirateTubeRack && aspirate_mmFromBottom === null) ||
(isDispenseTubeRack && dispense_mmFromBottom === null)
) {
return tipPositionedLowInTube()
} else {
return null
}
}

export const mixTipPositionInTube = (
fields: HydratedFormData
): FormWarning | null => {
Expand Down

0 comments on commit 04e00ad

Please sign in to comment.