Skip to content

Commit caf9a50

Browse files
shiyaochenshiyaochen
shiyaochen
authored and
shiyaochen
committed
add unit test
1 parent ca190b6 commit caf9a50

File tree

4 files changed

+77
-5
lines changed

4 files changed

+77
-5
lines changed

protocol-designer/src/assets/localization/en/tooltip.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"aspirate_mmFromBottom": "Adjust tip position for aspirate",
3838
"aspirate_touchTip_checkbox": "Touch tip to each side of the well after aspirating",
3939
"aspirate_touchTip_mmFromTop": "Distance from the top of the well",
40-
"aspirate_retract": " Withdraw the tip from the liquid after aspirating",
40+
"aspirate_retract": "Withdraw the tip from the liquid after aspirating",
4141
"aspirate_submerge": "Lower the tip into the liquid before aspirating",
4242
"aspirate_wells": "First select a source labware",
4343
"blowout_checkbox": "Blow extra air through the tip",

protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MoveLiquidTools/MultiInputField.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ interface MultiInputFieldProps {
2727
tooltipContent: string
2828
propsForFields: FieldPropsByName
2929
fields: StepInputFieldProps[]
30-
wellPosition?: boolean | null
30+
isWellPosition?: boolean | null
3131
labwareId?: string | null
3232
}
3333

@@ -36,7 +36,7 @@ export function MultiInputField(props: MultiInputFieldProps): JSX.Element {
3636
name,
3737
tab,
3838
tooltipContent,
39-
wellPosition,
39+
isWellPosition,
4040
fields,
4141
propsForFields,
4242
labwareId,
@@ -82,7 +82,7 @@ export function MultiInputField(props: MultiInputFieldProps): JSX.Element {
8282
errorToShow={errorToShow}
8383
/>
8484
))}
85-
{wellPosition != null && (
85+
{isWellPosition != null && (
8686
<PositionField
8787
padding="0"
8888
prefix={tab}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import { describe, it, expect, vi, beforeEach } from 'vitest'
2+
import { fireEvent, screen } from '@testing-library/react'
3+
import { i18n } from '../../../../../../../assets/localization'
4+
import { renderWithProviders } from '../../../../../../../__testing-utils__'
5+
import { MultiInputField } from '../MultiInputField'
6+
7+
import type { ComponentProps } from 'react'
8+
import { COLORS } from '@opentrons/components'
9+
10+
const render = (props: ComponentProps<typeof MultiInputField>) => {
11+
return renderWithProviders(<MultiInputField {...props} />, {
12+
i18nInstance: i18n,
13+
})
14+
}
15+
16+
describe('MultiInputField', () => {
17+
let props: ComponentProps<typeof MultiInputField>
18+
19+
beforeEach(() => {
20+
props = {
21+
name: 'Submerge',
22+
tab: 'aspirate',
23+
tooltipContent: 'some tooltip content',
24+
fields: [
25+
{
26+
fieldTitle: 'submerge speed',
27+
fieldKey: 'submerge_speed',
28+
units: 'mm/s',
29+
},
30+
{
31+
fieldTitle: 'submerge delay seconds',
32+
fieldKey: 'submerge_delay_seconds',
33+
units: 'mm',
34+
},
35+
],
36+
propsForFields: {
37+
aspirate_submerge_speed: {
38+
onFieldFocus: vi.fn(),
39+
onFieldBlur: vi.fn(),
40+
errorToShow: null,
41+
disabled: false,
42+
name: 'aspirate_submerge_speed',
43+
updateValue: vi.fn(),
44+
value: null,
45+
},
46+
},
47+
}
48+
})
49+
50+
it('should render input fields with caption and units wrapped by ListItem', () => {
51+
render(props)
52+
screen.getByText('Submerge')
53+
screen.getByTestId('information_icon')
54+
const listItem = screen.getByTestId('ListItem_noActive')
55+
expect(listItem).toHaveStyle(`backgroundColor: ${COLORS.grey20}`)
56+
screen.getByText('submerge speed')
57+
screen.getByText('mm/s')
58+
screen.getByText('submerge delay seconds')
59+
screen.getByText('mm')
60+
const inputs = screen.getAllByRole('textbox', { name: '' })
61+
expect(inputs).toHaveLength(2)
62+
fireEvent.change(inputs[0], { target: { value: ['5'] } })
63+
expect(
64+
props.propsForFields.aspirate_submerge_speed.updateValue
65+
).toHaveBeenCalled()
66+
})
67+
68+
it('should render a well position listbutton when isWellPosition is true', () => {
69+
props.isWellPosition = true
70+
render(props)
71+
})
72+
})

protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MoveLiquidTools/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ export function MoveLiquidTools(props: StepFormProps): JSX.Element {
362362
tooltipContent={t(`tooltip:step_fields.defaults.${tab}_retract`)}
363363
propsForFields={propsForFields}
364364
fields={getFields('retract')}
365-
wellPosition={true}
365+
isWellPosition={true}
366366
labwareId={
367367
formData[
368368
getLabwareFieldForPositioningField(

0 commit comments

Comments
 (0)