-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(app): extend SectionList component for Generic Step Screen #8513
Changes from 5 commits
2698e2f
d719074
9ef3247
71c2404
ed03c83
3261c8a
870023b
8e4e4b7
4ebbb0c
a28ca07
2da5499
5c8c579
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,35 @@ | ||
import * as React from 'react' | ||
import { ALIGN_START, Flex } from '@opentrons/components' | ||
import { LabwarePositionCheckStepDetail } from './LabwarePositionCheckStepDetail' | ||
import { PositionCheckNav } from './PositionCheckNav' | ||
import type { LabwarePositionCheckStep } from './types' | ||
import { useIntroInfo } from './hooks' | ||
|
||
interface GenericStepScreenProps { | ||
selectedStep: LabwarePositionCheckStep | ||
setCurrentLabwareCheckStep: (stepNumber: number) => void | ||
} | ||
export const GenericStepScreen = ( | ||
export function GenericStepScreen( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how come this got changed from a function expression to a function declaration? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh this is outdated now, ignore! 😄 |
||
props: GenericStepScreenProps | ||
): JSX.Element | null => { | ||
return <LabwarePositionCheckStepDetail selectedStep={props.selectedStep} /> | ||
): JSX.Element | null { | ||
const introInfo = useIntroInfo() | ||
const [sectionIndex] = React.useState<number>(0) | ||
if (introInfo == null) return null | ||
const { sections, primaryPipetteMount, secondaryPipetteMount } = introInfo | ||
|
||
return ( | ||
<React.Fragment> | ||
<Flex alignItems={ALIGN_START}> | ||
<PositionCheckNav | ||
primaryPipetteMount={primaryPipetteMount} | ||
secondaryPipetteMount={secondaryPipetteMount} | ||
sections={sections} | ||
currentSection={sections[sectionIndex]} | ||
/> | ||
<Flex> | ||
<LabwarePositionCheckStepDetail selectedStep={props.selectedStep} /> | ||
</Flex> | ||
</Flex> | ||
</React.Fragment> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,15 +7,29 @@ import { | |
import { i18n } from '../../../../i18n' | ||
import { GenericStepScreen } from '../GenericStepScreen' | ||
import { LabwarePositionCheckStepDetail } from '../LabwarePositionCheckStepDetail' | ||
import { PositionCheckNav } from '../PositionCheckNav' | ||
import { useIntroInfo } from '../hooks' | ||
import { Section } from '../types' | ||
|
||
jest.mock('../LabwarePositionCheckStepDetail') | ||
jest.mock('../PositionCheckNav') | ||
jest.mock('../hooks') | ||
|
||
const mockLabwarePositionCheckStepDetail = LabwarePositionCheckStepDetail as jest.MockedFunction< | ||
typeof LabwarePositionCheckStepDetail | ||
> | ||
const mockPositionCheckNav = PositionCheckNav as jest.MockedFunction< | ||
typeof PositionCheckNav | ||
> | ||
const mockUseIntroInfo = useIntroInfo as jest.MockedFunction< | ||
typeof useIntroInfo | ||
> | ||
|
||
const PICKUP_TIP_LABWARE_ID = 'PICKUP_TIP_LABWARE_ID' | ||
const PRIMARY_PIPETTE_ID = 'PRIMARY_PIPETTE_ID' | ||
const mockLabwarePositionCheckStepTipRack = { | ||
const MOCK_SECTION = ['PRIMARY_PIPETTE_TIPRACKS' as Section] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since this variable represents multiple sections, can we call it |
||
|
||
const MOCK_LABWARE_POSITION_CHECK_STEP_TIPRACK = { | ||
labwareId: | ||
'1d57fc10-67ad-11ea-9f8b-3b50068bd62d:opentrons/opentrons_96_filtertiprack_200ul/1', | ||
section: '', | ||
|
@@ -41,19 +55,39 @@ describe('GenericStepScreen', () => { | |
|
||
beforeEach(() => { | ||
props = { | ||
selectedStep: mockLabwarePositionCheckStepTipRack, | ||
selectedStep: MOCK_LABWARE_POSITION_CHECK_STEP_TIPRACK, | ||
setCurrentLabwareCheckStep: () => {}, | ||
} | ||
when(mockLabwarePositionCheckStepDetail) | ||
.calledWith( | ||
partialComponentPropsMatcher({ | ||
selectedStep: mockLabwarePositionCheckStepTipRack, | ||
selectedStep: MOCK_LABWARE_POSITION_CHECK_STEP_TIPRACK, | ||
}) | ||
) | ||
.mockReturnValue(<div>Mock Labware Position Check Step Detail</div>) | ||
|
||
mockPositionCheckNav.mockReturnValue(<div>Mock Position Check Nav</div>) | ||
when(mockUseIntroInfo).calledWith().mockReturnValue({ | ||
primaryTipRackSlot: '1', | ||
primaryTipRackName: 'Opentrons 96 Filter Tip Rack 200 µL', | ||
primaryPipetteMount: 'left', | ||
secondaryPipetteMount: '', | ||
numberOfTips: 1, | ||
firstStepLabwareSlot: '2', | ||
sections: MOCK_SECTION, | ||
}) | ||
}) | ||
it('renders LabwarePositionCheckStepDetail component', () => { | ||
const { getByText } = render(props) | ||
expect(getByText('Mock Labware Position Check Step Detail')).toBeTruthy() | ||
}) | ||
it('renders GenericStepScreenNav component', () => { | ||
const { getByText } = render(props) | ||
expect(getByText('Mock Position Check Nav')).toBeTruthy() | ||
}) | ||
it('renders null if useIntroInfo is null', () => { | ||
mockUseIntroInfo.mockReturnValue(null) | ||
const { container } = render(props) | ||
expect(container.firstChild).toBeNull() | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { renderWithProviders } from '@opentrons/components' | ||
import * as React from 'react' | ||
import { i18n } from '../../../../i18n' | ||
import { PositionCheckNav } from '../PositionCheckNav' | ||
import { Section } from '../types' | ||
|
||
const MOCK_SECTIONS_1_PIPETTE_2_STEPS = [ | ||
'PRIMARY_PIPETTE_TIPRACKS', | ||
'RETURN_TIP', | ||
] as Section[] | ||
const MOCK_SECTIONS_2_PIPETTES_3_STEPS = [ | ||
'PRIMARY_PIPETTE_TIPRACKS', | ||
'SECONDARY_PIPETTE_TIPRACKS', | ||
'RETURN_TIP', | ||
] as Section[] | ||
const MOCK_SECTIONS_2_PIPETTES_4_STEPS = [ | ||
'PRIMARY_PIPETTE_TIPRACKS', | ||
'SECONDARY_PIPETTE_TIPRACKS', | ||
'CHECK_REMAINING_LABWARE_WITH_PRIMARY_PIPETTE', | ||
'RETURN_TIP', | ||
] as Section[] | ||
|
||
const render = (props: React.ComponentProps<typeof PositionCheckNav>) => { | ||
return renderWithProviders(<PositionCheckNav {...props} />, { | ||
i18nInstance: i18n, | ||
})[0] | ||
} | ||
|
||
describe('PositionCheckNav', () => { | ||
let props: React.ComponentProps<typeof PositionCheckNav> | ||
|
||
beforeEach(() => { | ||
props = { | ||
sections: MOCK_SECTIONS_1_PIPETTE_2_STEPS, | ||
currentSection: 'PRIMARY_PIPETTE_TIPRACKS', | ||
primaryPipetteMount: 'left', | ||
secondaryPipetteMount: '', | ||
} | ||
}) | ||
it('renders a 2 step Nav with 1 pipette', () => { | ||
const { getByText } = render(props) | ||
expect(getByText('1')).toHaveStyle('backgroundColor: #00c3e6') | ||
expect(getByText('Check tipracks with Left Pipette')).toBeTruthy() | ||
expect(getByText('2')).toHaveStyle('backgroundColor: C_DISABLED') | ||
expect(getByText('Return tip')).toBeTruthy() | ||
}) | ||
it('renders a 3 step Nav with 2 pipettes', () => { | ||
props = { | ||
sections: MOCK_SECTIONS_2_PIPETTES_3_STEPS, | ||
currentSection: 'PRIMARY_PIPETTE_TIPRACKS', | ||
primaryPipetteMount: 'left', | ||
secondaryPipetteMount: 'right', | ||
} | ||
const { getByText } = render(props) | ||
expect(getByText('1')).toHaveStyle('backgroundColor: #00c3e6') | ||
expect(getByText('Check tipracks with Left Pipette')).toBeTruthy() | ||
expect(getByText('2')).toHaveStyle('backgroundColor: C_DISABLED') | ||
expect(getByText('Check tipracks with Right Pipette')).toBeTruthy() | ||
expect(getByText('3')).toHaveStyle('backgroundColor: C_DISABLED') | ||
expect(getByText('Return tip')).toBeTruthy() | ||
}) | ||
it('renders a 4 step Nav with 2 pipettes', () => { | ||
props = { | ||
sections: MOCK_SECTIONS_2_PIPETTES_4_STEPS, | ||
currentSection: 'PRIMARY_PIPETTE_TIPRACKS', | ||
primaryPipetteMount: 'left', | ||
secondaryPipetteMount: 'right', | ||
} | ||
const { getByText } = render(props) | ||
expect(getByText('1')).toHaveStyle('backgroundColor: #00c3e6') | ||
expect(getByText('Check tipracks with Left Pipette')).toBeTruthy() | ||
expect(getByText('2')).toHaveStyle('backgroundColor: C_DISABLED') | ||
expect(getByText('Check tipracks with Right Pipette')).toBeTruthy() | ||
expect(getByText('3')).toHaveStyle('backgroundColor: C_DISABLED') | ||
expect(getByText('Check remaining labware with Left Pipette')).toBeTruthy() | ||
expect(getByText('4')).toHaveStyle('backgroundColor: C_DISABLED') | ||
expect(getByText('Return tip')).toBeTruthy() | ||
}) | ||
it('renders a 3 step Nav with 2 pipettes and on the second step', () => { | ||
props = { | ||
sections: MOCK_SECTIONS_2_PIPETTES_3_STEPS, | ||
currentSection: 'SECONDARY_PIPETTE_TIPRACKS', | ||
primaryPipetteMount: 'left', | ||
secondaryPipetteMount: 'right', | ||
completedSections: ['PRIMARY_PIPETTE_TIPRACKS'], | ||
} | ||
const { getByText } = render(props) | ||
expect(getByText('Check tipracks with Left Pipette')).toBeTruthy() | ||
expect(getByText('2')).toHaveStyle('backgroundColor: #00c3e6') | ||
expect(getByText('Check tipracks with Right Pipette')).toBeTruthy() | ||
expect(getByText('3')).toHaveStyle('backgroundColor: C_DISABLED') | ||
expect(getByText('Return tip')).toBeTruthy() | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: the type import should go last