Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
koji committed Oct 30, 2023
1 parent dbd6336 commit d06ad0d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'
import { useTranslation } from 'react-i18next'
import map from 'lodash/map'

import {
BaseDeck,
Expand All @@ -12,12 +13,15 @@ import {
inferModuleOrientationFromXCoordinate,
FLEX_ROBOT_TYPE,
} from '@opentrons/shared-data'
import { parseInitialLoadedLabwareByAdapter } from '@opentrons/api-client'

import { Modal } from '../../molecules/Modal'
import { ModuleInfo } from '../Devices/ModuleInfo'
import { ROBOT_MODEL_OT3 } from '../../redux/discovery' // need to switch if needed to use this
import { useFeatureFlag } from '../../redux/config'
import { getDeckConfigFromProtocolCommands } from '../../resources/deck_configuration/utils'
import { useStoredProtocolAnalysis } from '../Devices/hooks'
import { getLabwareRenderInfo } from '../Devices/ProtocolRun/utils/getLabwareRenderInfo'
import { getStandardDeckViewLayerBlockList } from '../Devices/ProtocolRun/utils/getStandardDeckViewLayerBlockList'

import type {
Expand Down Expand Up @@ -81,6 +85,30 @@ export function ModulesAndDeckMapViewModal({
),
}))

const initialLoadedLabwareByAdapter = parseInitialLoadedLabwareByAdapter(
protocolAnalysis.commands
)
const labwareRenderInfo = getLabwareRenderInfo(protocolAnalysis, deckDef)

const labwareLocations = map(
labwareRenderInfo,
({ labwareDef, displayName, slotName }, labwareId) => {
const labwareInAdapter = initialLoadedLabwareByAdapter[labwareId]

Check warning on line 96 in app/src/organisms/ProtocolSetupModulesAndDeck/ModulesAndDeckMapViewModal.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/organisms/ProtocolSetupModulesAndDeck/ModulesAndDeckMapViewModal.tsx#L96

Added line #L96 was not covered by tests
const topLabwareDefinition =
labwareInAdapter?.result?.definition ?? labwareDef
const topLabwareId = labwareInAdapter?.result?.labwareId ?? labwareId
const topLabwareDisplayName =
labwareInAdapter?.params.displayName ?? displayName

return {

Check warning on line 103 in app/src/organisms/ProtocolSetupModulesAndDeck/ModulesAndDeckMapViewModal.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/organisms/ProtocolSetupModulesAndDeck/ModulesAndDeckMapViewModal.tsx#L103

Added line #L103 was not covered by tests
labwareLocation: { slotName },
definition: topLabwareDefinition,
topLabwareId,
topLabwareDisplayName,
}
}
)

return (
<Modal
header={modalHeader}
Expand All @@ -95,7 +123,7 @@ export function ModulesAndDeckMapViewModal({
FLEX_ROBOT_TYPE
)}
robotType={FLEX_ROBOT_TYPE}
labwareLocations={[]}
labwareLocations={labwareLocations}
moduleLocations={moduleLocations}
/>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import {
EXTENDED_DECK_CONFIG_FIXTURE,
} from '@opentrons/components'
// import { FLEX_ROBOT_TYPE } from '@opentrons/shared-data'
// import { parseInitialLoadedLabwareByAdapter } from '@opentrons/api-client'

import { i18n } from '../../../i18n'
import { useFeatureFlag } from '../../../redux/config'
import { useStoredProtocolAnalysis } from '../../Devices/hooks'
import { getDeckConfigFromProtocolCommands } from '../../../resources/deck_configuration/utils'
import { getLabwareRenderInfo } from '../../Devices/ProtocolRun/utils/getLabwareRenderInfo'
// import { getStandardDeckViewLayerBlockList } from '../../Devices/ProtocolRun/utils/getStandardDeckViewLayerBlockList'
import _uncastedSimpleV7Protocol from '@opentrons/shared-data/protocol/fixtures/7/simpleV7.json'
import { ModulesAndDeckMapViewModal } from '../ModulesAndDeckMapViewModal'
Expand All @@ -21,10 +23,12 @@ import type { ProtocolAnalysisOutput } from '@opentrons/shared-data'

jest.mock('@opentrons/components/src/hardware-sim/BaseDeck')
jest.mock('@opentrons/components/src/hardware-sim/Deck/RobotWorkSpace')
jest.mock('@opentrons/api-client')
jest.mock('../../../redux/config')
jest.mock('../../Devices/hooks')
jest.mock('../../../resources/deck_configuration/utils')
jest.mock('../../Devices/ModuleInfo')
jest.mock('../../Devices/ProtocolRun/utils/getLabwareRenderInfo')

const mockRunId = 'mockRunId'
const mockSetShowDeckMapModal = jest.fn()
Expand Down Expand Up @@ -124,6 +128,9 @@ const mockUseStoredProtocolAnalysis = useStoredProtocolAnalysis as jest.MockedFu
const mockGetDeckConfigFromProtocolCommands = getDeckConfigFromProtocolCommands as jest.MockedFunction<
typeof getDeckConfigFromProtocolCommands
>
const mockGetLabwareRenderInfo = getLabwareRenderInfo as jest.MockedFunction<
typeof getLabwareRenderInfo
>

describe('ModulesAndDeckMapViewModal', () => {
let props: React.ComponentProps<typeof ModulesAndDeckMapViewModal>
Expand Down Expand Up @@ -156,6 +163,7 @@ describe('ModulesAndDeckMapViewModal', () => {
// .mockReturnValue(<div>mock BaseDeck</div>)
mockBaseDeck.mockReturnValue(<div>mock BaseDeck</div>)
mockRobotWorkSpace.mockReturnValue(<div>mock RobotWorkSpace</div>)
mockGetLabwareRenderInfo.mockReturnValue({})
})

afterEach(() => {
Expand Down

0 comments on commit d06ad0d

Please sign in to comment.