-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(app): update LPC description copy (#8493)
closes #8215
- Loading branch information
Showing
3 changed files
with
127 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
app/src/organisms/ProtocolSetup/LabwarePositionCheck/__tests__/IntroScreen.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import * as React from 'react' | ||
import { when } from 'jest-when' | ||
import { | ||
partialComponentPropsMatcher, | ||
renderWithProviders, | ||
} from '@opentrons/components/src/testing/utils' | ||
import { RobotWorkSpace } from '@opentrons/components' | ||
import { i18n } from '../../../../i18n' | ||
import standardDeckDef from '@opentrons/shared-data/deck/definitions/2/ot2_standard.json' | ||
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 { useIntroInfo } from '../hooks' | ||
import { IntroScreen } from '../IntroScreen' | ||
import type { Section } from '../types' | ||
|
||
jest.mock('../hooks') | ||
jest.mock('../PositionCheckNav') | ||
jest.mock('../../hooks') | ||
jest.mock('@opentrons/components', () => { | ||
const actualComponents = jest.requireActual('@opentrons/components') | ||
return { | ||
...actualComponents, | ||
RobotWorkSpace: jest.fn(() => <div>mock RobotWorkSpace</div>), | ||
} | ||
}) | ||
|
||
const mockUseModuleRenderInfoById = useModuleRenderInfoById as jest.MockedFunction< | ||
typeof useModuleRenderInfoById | ||
> | ||
const mockUseLabwareRenderInfoById = useLabwareRenderInfoById as jest.MockedFunction< | ||
typeof useLabwareRenderInfoById | ||
> | ||
const mockUseIntroInfo = useIntroInfo as jest.MockedFunction< | ||
typeof useIntroInfo | ||
> | ||
const mockPositionCheckNav = PositionCheckNav as jest.MockedFunction< | ||
typeof PositionCheckNav | ||
> | ||
const mockRobotWorkSpace = RobotWorkSpace as jest.MockedFunction< | ||
typeof RobotWorkSpace | ||
> | ||
const deckSlotsById = standardDeckDef.locations.orderedSlots.reduce( | ||
(acc, deckSlot) => ({ ...acc, [deckSlot.id]: deckSlot }), | ||
{} | ||
) | ||
const MOCK_SECTIONS = ['MOCK_PRIMARY_PIPETTE_TIPRACKS' as Section] | ||
const MOCK_300_UL_TIPRACK_COORDS = [30, 40, 0] | ||
|
||
const render = (props: React.ComponentProps<typeof IntroScreen>) => { | ||
return renderWithProviders(<IntroScreen {...props} />, { | ||
i18nInstance: i18n, | ||
})[0] | ||
} | ||
|
||
describe('IntroScreen', () => { | ||
let props: React.ComponentProps<typeof IntroScreen> | ||
|
||
beforeEach(() => { | ||
props = { | ||
setCurrentLabwareCheckStep: () => {}, | ||
} | ||
when(mockRobotWorkSpace) | ||
.mockReturnValue(<div></div>) // this (default) empty div will be returned when RobotWorkSpace isn't called with expected props | ||
.calledWith( | ||
partialComponentPropsMatcher({ | ||
deckDef: standardDeckDef, | ||
children: expect.anything(), | ||
}) | ||
) | ||
.mockImplementation(({ children }) => ( | ||
<svg> | ||
{/* @ts-expect-error children won't be null since we checked for expect.anything() above */} | ||
{children({ | ||
deckSlotsById, | ||
getRobotCoordsFromDOMCoords: {} as any, | ||
})} | ||
</svg> | ||
)) | ||
when(mockUseLabwareRenderInfoById) | ||
.calledWith() | ||
.mockReturnValue({ | ||
'300_ul_tiprack_id': { | ||
labwareDef: fixture_tiprack_300_ul as LabwareDefinition2, | ||
x: MOCK_300_UL_TIPRACK_COORDS[0], | ||
y: MOCK_300_UL_TIPRACK_COORDS[1], | ||
z: MOCK_300_UL_TIPRACK_COORDS[2], | ||
}, | ||
}) | ||
when(mockUseModuleRenderInfoById).calledWith().mockReturnValue({}) | ||
|
||
when(mockUseIntroInfo).calledWith().mockReturnValue({ | ||
primaryTipRackSlot: '1', | ||
primaryTipRackName: 'Opentrons 96 Tip Rack 300 µL', | ||
primaryPipetteMount: 'left', | ||
secondaryPipetteMount: '', | ||
numberOfTips: 1, | ||
firstStepLabwareSlot: '2', | ||
sections: MOCK_SECTIONS, | ||
}) | ||
mockPositionCheckNav.mockReturnValue(<div>Mock Position Check Nav</div>) | ||
}) | ||
|
||
it('renders correct heading and position_check_description', () => { | ||
const { getByRole, getByText } = render(props) | ||
getByRole('heading', { | ||
name: 'Labware Position Check Overview', | ||
}) | ||
getByText( | ||
'Labware Position Check is a guided workflow that checks every labware on the deck for an added degree of precision in your protocol.' | ||
) | ||
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') | ||
}) | ||
}) |