Skip to content

Commit

Permalink
refactor(protocol-designer): increased test coverage for ConnectedSte…
Browse files Browse the repository at this point in the history
…pItem (#14900)

closes AUTH-300
  • Loading branch information
jerader authored and Carlos-fernandez committed May 20, 2024
1 parent f745757 commit dbec91c
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 3 deletions.
7 changes: 6 additions & 1 deletion protocol-designer/src/components/lists/TitledStepList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ export function TitledStepList(props: Props): JSX.Element {
</div>
)}
{iconName && (
<Icon {...iconProps} className={iconClass} name={iconName} />
<Icon
{...iconProps}
data-testid={`TitledStepList_icon_${iconName}`}
className={iconClass}
name={iconName}
/>
)}
<h3 className={styles.title}>{props.title}</h3>
{collapsible && (
Expand Down
136 changes: 134 additions & 2 deletions protocol-designer/src/containers/__tests__/ConnectedStepItem.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as React from 'react'
import { describe, it, beforeEach, vi } from 'vitest'
import { screen } from '@testing-library/react'
import { fixture96Plate } from '@opentrons/shared-data'
import '@testing-library/jest-dom/vitest'
import { fixture96Plate, fixtureTiprack1000ul } from '@opentrons/shared-data'
import { renderWithProviders } from '../../__testing-utils__'
import { i18n } from '../../localization'
import {
Expand Down Expand Up @@ -49,8 +50,9 @@ const heaterShakerStepId = 'hsStepId'
const thermocyclerStepId = 'tcStepId'
const temperatureStepId = 'tempStepId'
const moveLabwareStepId = 'moveLabwareId'
const mixStepId = 'mixStepId'
const moveLiquidStepId = 'moveLiquidStepId'

// TODO(jr, 4/8/24): add test coverage for mix and moveLiquid!!!
describe('ConnectedStepItem', () => {
let props: React.ComponentProps<typeof ConnectedStepItem>
beforeEach(() => {
Expand Down Expand Up @@ -89,6 +91,14 @@ describe('ConnectedStepItem', () => {
stepType: 'moveLabware',
id: moveLabwareStepId,
},
[mixStepId]: {
stepType: 'mix',
id: mixStepId,
},
[moveLiquidStepId]: {
stepType: 'moveLiquid',
id: moveLiquidStepId,
},
})
vi.mocked(getArgsAndErrorsByStepId).mockReturnValue({
[pauseStepId]: {
Expand All @@ -115,6 +125,14 @@ describe('ConnectedStepItem', () => {
errors: false,
stepArgs: null,
},
[mixStepId]: {
errors: false,
stepArgs: null,
},
[moveLiquidStepId]: {
errors: false,
stepArgs: null,
},
})
vi.mocked(getErrorStepId).mockReturnValue(null)
vi.mocked(getHasTimelineWarningsPerStep).mockReturnValue({
Expand All @@ -124,6 +142,8 @@ describe('ConnectedStepItem', () => {
[thermocyclerStepId]: false,
[temperatureStepId]: false,
[moveLabwareStepId]: false,
[mixStepId]: false,
[moveLiquidStepId]: false,
})
vi.mocked(getHasFormLevelWarningsPerStep).mockReturnValue({
[pauseStepId]: false,
Expand All @@ -132,6 +152,8 @@ describe('ConnectedStepItem', () => {
[thermocyclerStepId]: false,
[temperatureStepId]: false,
[moveLabwareStepId]: false,
[mixStepId]: false,
[moveLiquidStepId]: false,
})
vi.mocked(getInitialDeckSetup).mockReturnValue({
pipettes: {},
Expand Down Expand Up @@ -179,6 +201,12 @@ describe('ConnectedStepItem', () => {
slot: 'A2',
def: fixture96Plate as LabwareDefinition2,
},
tipId: {
id: 'tipId',
labwareDefURI: `opentrons/${fixtureTiprack1000ul.parameters.loadName}/1`,
slot: 'D2',
def: fixtureTiprack1000ul as LabwareDefinition2,
},
},
})
vi.mocked(getCollapsedSteps).mockReturnValue({
Expand All @@ -188,6 +216,8 @@ describe('ConnectedStepItem', () => {
[thermocyclerStepId]: true,
[temperatureStepId]: true,
[moveLabwareStepId]: true,
[mixStepId]: true,
[moveLiquidStepId]: true,
})
vi.mocked(getHoveredSubstep).mockReturnValue(null)
vi.mocked(getSelectedStepId).mockReturnValue(pauseStepId)
Expand All @@ -198,6 +228,8 @@ describe('ConnectedStepItem', () => {
thermocyclerStepId,
moveLabwareStepId,
temperatureStepId,
mixStepId,
moveLiquidStepId,
])
vi.mocked(getMultiSelectItemIds).mockReturnValue(null)
vi.mocked(getMultiSelectLastSelected).mockReturnValue(null)
Expand Down Expand Up @@ -260,6 +292,32 @@ describe('ConnectedStepItem', () => {
newLocation: { slotName: 'B2' },
},
},
[mixStepId]: {
substepType: 'sourceDest',
multichannel: false,
commandCreatorFnName: 'mix',
parentStepId: mixStepId,
rows: [
{
activeTips: null,
},
],
},
[moveLiquidStepId]: {
substepType: 'sourceDest',
multichannel: false,
commandCreatorFnName: 'transfer',
parentStepId: moveLiquidStepId,
rows: [
{
activeTips: { labwareId: 'tipId', wellName: 'A1' },
substepIndex: 2,
source: { well: 'A1', preIngreds: {}, postIngreds: {} },
dest: { well: 'A1', preIngreds: {}, postIngreds: {} },
volume: 50,
},
],
},
})
vi.mocked(labwareIngredSelectors.getLiquidNamesById).mockReturnValue({})
vi.mocked(getLabwareNicknamesById).mockReturnValue({})
Expand All @@ -286,6 +344,8 @@ describe('ConnectedStepItem', () => {
[thermocyclerStepId]: true,
[temperatureStepId]: true,
[moveLabwareStepId]: true,
[mixStepId]: true,
[moveLiquidStepId]: true,
})
vi.mocked(getSelectedStepId).mockReturnValue(magnetStepId)
props.stepId = magnetStepId
Expand All @@ -303,6 +363,8 @@ describe('ConnectedStepItem', () => {
[thermocyclerStepId]: true,
[temperatureStepId]: true,
[moveLabwareStepId]: true,
[mixStepId]: true,
[moveLiquidStepId]: true,
})
vi.mocked(getSelectedStepId).mockReturnValue(heaterShakerStepId)
props.stepId = heaterShakerStepId
Expand All @@ -326,6 +388,8 @@ describe('ConnectedStepItem', () => {
[thermocyclerStepId]: false,
[temperatureStepId]: true,
[moveLabwareStepId]: true,
[mixStepId]: true,
[moveLiquidStepId]: true,
})
vi.mocked(getSelectedStepId).mockReturnValue(thermocyclerStepId)
props.stepId = thermocyclerStepId
Expand All @@ -348,6 +412,8 @@ describe('ConnectedStepItem', () => {
[thermocyclerStepId]: true,
[temperatureStepId]: false,
[moveLabwareStepId]: true,
[mixStepId]: true,
[moveLiquidStepId]: true,
})
vi.mocked(getSelectedStepId).mockReturnValue(temperatureStepId)
props.stepId = temperatureStepId
Expand All @@ -367,6 +433,8 @@ describe('ConnectedStepItem', () => {
[thermocyclerStepId]: true,
[temperatureStepId]: true,
[moveLabwareStepId]: false,
[mixStepId]: true,
[moveLiquidStepId]: true,
})
vi.mocked(getSelectedStepId).mockReturnValue(moveLabwareStepId)
props.stepId = moveLabwareStepId
Expand All @@ -376,4 +444,68 @@ describe('ConnectedStepItem', () => {
screen.getByText('labware')
screen.getByText('new location')
})
it('renders an expanded step for mix', () => {
vi.mocked(getCollapsedSteps).mockReturnValue({
[pauseStepId]: true,
[magnetStepId]: true,
[heaterShakerStepId]: true,
[thermocyclerStepId]: true,
[temperatureStepId]: true,
[moveLabwareStepId]: true,
[mixStepId]: false,
[moveLiquidStepId]: true,
})
vi.mocked(getSelectedStepId).mockReturnValue(mixStepId)
props.stepId = mixStepId
render(props)
screen.getByText('2. mix')
screen.getByText('uL')
screen.getByText('μL')
})
it('renders an expanded step for move liquid (transfer)', () => {
vi.mocked(getCollapsedSteps).mockReturnValue({
[pauseStepId]: true,
[magnetStepId]: true,
[heaterShakerStepId]: true,
[thermocyclerStepId]: true,
[temperatureStepId]: true,
[moveLabwareStepId]: true,
[mixStepId]: true,
[moveLiquidStepId]: false,
})
vi.mocked(getSelectedStepId).mockReturnValue(moveLiquidStepId)
props.stepId = moveLiquidStepId
render(props)
screen.getByText('2. transfer')
screen.getByText('ASPIRATE')
screen.getByText('DISPENSE')
screen.getAllByText('A1')
screen.getByText('50 μL')
})
it('renders a timeline warning icon for move liquid', () => {
vi.mocked(getHasTimelineWarningsPerStep).mockReturnValue({
[pauseStepId]: false,
[magnetStepId]: false,
[heaterShakerStepId]: false,
[thermocyclerStepId]: false,
[temperatureStepId]: false,
[moveLabwareStepId]: false,
[mixStepId]: false,
[moveLiquidStepId]: true,
})
vi.mocked(getCollapsedSteps).mockReturnValue({
[pauseStepId]: true,
[magnetStepId]: true,
[heaterShakerStepId]: true,
[thermocyclerStepId]: true,
[temperatureStepId]: true,
[moveLabwareStepId]: true,
[mixStepId]: true,
[moveLiquidStepId]: false,
})
vi.mocked(getSelectedStepId).mockReturnValue(moveLiquidStepId)
props.stepId = moveLiquidStepId
render(props)
screen.getByTestId('TitledStepList_icon_alert-circle')
})
})

0 comments on commit dbec91c

Please sign in to comment.