From d06ad0d29edc422c427c7667d7380f7743558dde Mon Sep 17 00:00:00 2001 From: koji Date: Mon, 30 Oct 2023 11:08:58 -0400 Subject: [PATCH] fix tests --- .../ModulesAndDeckMapViewModal.tsx | 30 ++++++++++++++++++- .../ModulesAndDeckMapViewModal.test.tsx | 8 +++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/app/src/organisms/ProtocolSetupModulesAndDeck/ModulesAndDeckMapViewModal.tsx b/app/src/organisms/ProtocolSetupModulesAndDeck/ModulesAndDeckMapViewModal.tsx index 4a91e67bf9e..7f6e9047e48 100644 --- a/app/src/organisms/ProtocolSetupModulesAndDeck/ModulesAndDeckMapViewModal.tsx +++ b/app/src/organisms/ProtocolSetupModulesAndDeck/ModulesAndDeckMapViewModal.tsx @@ -1,5 +1,6 @@ import React from 'react' import { useTranslation } from 'react-i18next' +import map from 'lodash/map' import { BaseDeck, @@ -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 { @@ -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] + const topLabwareDefinition = + labwareInAdapter?.result?.definition ?? labwareDef + const topLabwareId = labwareInAdapter?.result?.labwareId ?? labwareId + const topLabwareDisplayName = + labwareInAdapter?.params.displayName ?? displayName + + return { + labwareLocation: { slotName }, + definition: topLabwareDefinition, + topLabwareId, + topLabwareDisplayName, + } + } + ) + return ( ) : ( diff --git a/app/src/organisms/ProtocolSetupModulesAndDeck/__tests__/ModulesAndDeckMapViewModal.test.tsx b/app/src/organisms/ProtocolSetupModulesAndDeck/__tests__/ModulesAndDeckMapViewModal.test.tsx index b4a244b158f..0ea8d74ba43 100644 --- a/app/src/organisms/ProtocolSetupModulesAndDeck/__tests__/ModulesAndDeckMapViewModal.test.tsx +++ b/app/src/organisms/ProtocolSetupModulesAndDeck/__tests__/ModulesAndDeckMapViewModal.test.tsx @@ -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' @@ -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() @@ -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 @@ -156,6 +163,7 @@ describe('ModulesAndDeckMapViewModal', () => { // .mockReturnValue(
mock BaseDeck
) mockBaseDeck.mockReturnValue(
mock BaseDeck
) mockRobotWorkSpace.mockReturnValue(
mock RobotWorkSpace
) + mockGetLabwareRenderInfo.mockReturnValue({}) }) afterEach(() => {