Skip to content
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

Merged
merged 12 commits into from
Oct 13, 2021
Prev Previous commit
Next Next commit
rename PositionCheckNav to SectionList
  • Loading branch information
jerader committed Oct 13, 2021
commit a28ca07198417964399545bee7824ecaa9a95482
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
SPACING_3,
} from '@opentrons/components'
import { LabwarePositionCheckStepDetail } from './LabwarePositionCheckStepDetail'
import { PositionCheckNav } from './PositionCheckNav'
import { SectionList } from './SectionList'
import type { LabwarePositionCheckStep } from './types'
import { useIntroInfo } from './hooks'

Expand All @@ -25,7 +25,7 @@ export const GenericStepScreen = (
return (
<Box margin={SPACING_3}>
<Flex justifyContent={JUSTIFY_SPACE_BETWEEN} alignItems={ALIGN_CENTER}>
<PositionCheckNav
<SectionList
primaryPipetteMount={primaryPipetteMount}
secondaryPipetteMount={secondaryPipetteMount}
sections={sections}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
SPACING_4,
FONT_SIZE_BODY_2,
} from '@opentrons/components'
import { PositionCheckNav } from './PositionCheckNav'
import { SectionList } from './SectionList'
import { DeckMap } from './DeckMap'
import { useIntroInfo, useLabwareIdsBySection } from './hooks'

Expand Down Expand Up @@ -63,7 +63,7 @@ export const IntroScreen = (props: {
}}
></Trans>
<Flex justifyContent={JUSTIFY_SPACE_BETWEEN} alignItems={ALIGN_CENTER}>
<PositionCheckNav
<SectionList
sections={sections}
currentSection={currentSection}
primaryPipetteMount={primaryPipetteMount}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface Props {
completedSections?: Section[]
}

export function PositionCheckNav(props: Props): JSX.Element {
export function SectionList(props: Props): JSX.Element {
const {
currentSection,
sections,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@ import {
import { i18n } from '../../../../i18n'
import { GenericStepScreen } from '../GenericStepScreen'
import { LabwarePositionCheckStepDetail } from '../LabwarePositionCheckStepDetail'
import { PositionCheckNav } from '../PositionCheckNav'
import { SectionList } from '../SectionList'
import { useIntroInfo } from '../hooks'
import { Section } from '../types'

jest.mock('../LabwarePositionCheckStepDetail')
jest.mock('../PositionCheckNav')
jest.mock('../SectionList')
jest.mock('../hooks')

const mockLabwarePositionCheckStepDetail = LabwarePositionCheckStepDetail as jest.MockedFunction<
typeof LabwarePositionCheckStepDetail
>
const mockPositionCheckNav = PositionCheckNav as jest.MockedFunction<
typeof PositionCheckNav
>
const mockSectionList = SectionList as jest.MockedFunction<typeof SectionList>
const mockUseIntroInfo = useIntroInfo as jest.MockedFunction<
typeof useIntroInfo
>
Expand Down Expand Up @@ -66,7 +64,7 @@ describe('GenericStepScreen', () => {
)
.mockReturnValue(<div>Mock Labware Position Check Step Detail</div>)

mockPositionCheckNav.mockReturnValue(<div>Mock Position Check Nav</div>)
mockSectionList.mockReturnValue(<div>Mock SectionList </div>)
when(mockUseIntroInfo).calledWith().mockReturnValue({
primaryTipRackSlot: '1',
primaryTipRackName: 'Opentrons 96 Filter Tip Rack 200 µL',
Expand All @@ -83,7 +81,7 @@ describe('GenericStepScreen', () => {
})
it('renders GenericStepScreenNav component', () => {
const { getByText } = render(props)
expect(getByText('Mock Position Check Nav')).toBeTruthy()
expect(getByText('Mock SectionList')).toBeTruthy()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be replaced with just getByText('Mock SectionList')

})
it('renders null if useIntroInfo is null', () => {
mockUseIntroInfo.mockReturnValue(null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import standardDeckDef from '@opentrons/shared-data/deck/definitions/2/ot2_stand
import { LabwareDefinition2 } from '@opentrons/shared-data'
import fixture_tiprack_300_ul from '@opentrons/shared-data/labware/fixtures/2/fixture_tiprack_300_ul.json'
import { useModuleRenderInfoById, useLabwareRenderInfoById } from '../../hooks'
import { PositionCheckNav } from '../PositionCheckNav'
import { SectionList } from '../SectionList'
import { useIntroInfo, useLabwareIdsBySection } from '../hooks'
import { IntroScreen, INTERVAL_MS } from '../IntroScreen'
import type { Section } from '../types'
import { fireEvent } from '@testing-library/dom'

jest.mock('../hooks')
jest.mock('../PositionCheckNav')
jest.mock('../Sectionlist')
jest.mock('../../hooks')
jest.mock('@opentrons/components', () => {
const actualComponents = jest.requireActual('@opentrons/components')
Expand All @@ -42,9 +42,7 @@ const mockUseIntroInfo = useIntroInfo as jest.MockedFunction<
typeof useIntroInfo
>
const mockUseInterval = useInterval as jest.MockedFunction<typeof useInterval>
const mockPositionCheckNav = PositionCheckNav as jest.MockedFunction<
typeof PositionCheckNav
>
const mockSectionList = SectionList as jest.MockedFunction<typeof SectionList>
const mockRobotWorkSpace = RobotWorkSpace as jest.MockedFunction<
typeof RobotWorkSpace
>
Expand Down Expand Up @@ -107,7 +105,7 @@ describe('IntroScreen', () => {
firstStepLabwareSlot: '2',
sections: MOCK_SECTIONS,
})
mockPositionCheckNav.mockReturnValue(<div>Mock Position Check Nav</div>)
mockSectionList.mockReturnValue(<div>Mock Section List</div>)
})
afterEach(() => {
resetAllWhenMocks()
Expand All @@ -125,7 +123,7 @@ describe('IntroScreen', () => {
getByText(
'When you check a labware, the OT-2’s pipette nozzle or attached tip will stop at the center of the A1 well. If the pipette nozzle or tip is not centered, you can reveal the OT-2’s jog controls to make an adjustment. This Labware Offset will be applied to the entire labware. Offset data is measured to the nearest 1/10th mm and can be made in the X, Y and/or Z directions.'
)
getByText('Mock Position Check Nav')
getByText('Mock Section List')
})
it('should call setCurrentLabwareCheckStep when the CTA button is pressed', () => {
const { getByRole } = render(props)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { renderWithProviders } from '@opentrons/components'
import * as React from 'react'
import { i18n } from '../../../../i18n'
import { PositionCheckNav } from '../PositionCheckNav'
import { SectionList } from '../SectionList'
import { Section } from '../types'

const MOCK_SECTIONS_1_PIPETTE_2_STEPS = [
Expand All @@ -20,14 +20,14 @@ const MOCK_SECTIONS_2_PIPETTES_4_STEPS = [
'RETURN_TIP',
] as Section[]

const render = (props: React.ComponentProps<typeof PositionCheckNav>) => {
return renderWithProviders(<PositionCheckNav {...props} />, {
const render = (props: React.ComponentProps<typeof SectionList>) => {
return renderWithProviders(<SectionList {...props} />, {
i18nInstance: i18n,
})[0]
}

describe('PositionCheckNav', () => {
let props: React.ComponentProps<typeof PositionCheckNav>
describe('SectionList', () => {
let props: React.ComponentProps<typeof SectionList>

beforeEach(() => {
props = {
Expand Down