From 80c704e33b4590db7304f4ab3ac21be12e64d432 Mon Sep 17 00:00:00 2001 From: ncdiehl11 Date: Thu, 7 Dec 2023 16:53:38 -0500 Subject: [PATCH 1/2] fix(app): properly display no liquids used text in protocol details/setup When we decide whether or not to display liquids in ProtocolDetails or ProtocolSetup, we need to determine if the liquids are actually loaded in protocol (commands) rather than accessing the liquids property of the protocol analysis. --- .../Devices/ProtocolRun/ProtocolRunSetup.tsx | 17 ++++++++++++++--- .../__tests__/ProtocolRunSetup.test.tsx | 9 ++++++++- .../ProtocolDetails/ProtocolLiquidsDetails.tsx | 2 +- .../__tests__/ProtocolLiquidsDetails.test.tsx | 1 + 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/app/src/organisms/Devices/ProtocolRun/ProtocolRunSetup.tsx b/app/src/organisms/Devices/ProtocolRun/ProtocolRunSetup.tsx index e6e07c9f3f8..8414684d584 100644 --- a/app/src/organisms/Devices/ProtocolRun/ProtocolRunSetup.tsx +++ b/app/src/organisms/Devices/ProtocolRun/ProtocolRunSetup.tsx @@ -1,7 +1,10 @@ import * as React from 'react' import { useTranslation } from 'react-i18next' -import { parseAllRequiredModuleModels } from '@opentrons/api-client' +import { + parseAllRequiredModuleModels, + parseLiquidsInLoadOrder, +} from '@opentrons/api-client' import { ALIGN_CENTER, COLORS, @@ -133,8 +136,16 @@ export function ProtocolRunSetup({ }) if (robot == null) return null - const hasLiquids = - protocolAnalysis != null && protocolAnalysis.liquids?.length > 0 + + const liquids = protocolAnalysis?.liquids ?? [] + + const liquidsInLoadOrder = + protocolAnalysis != null + ? parseLiquidsInLoadOrder(liquids, protocolAnalysis.commands) + : [] + + const hasLiquids = protocolAnalysis != null && liquidsInLoadOrder.length > 0 + const hasModules = protocolAnalysis != null && modules.length > 0 const protocolDeckConfig = getSimplestDeckConfigForProtocol(protocolAnalysis) diff --git a/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunSetup.test.tsx b/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunSetup.test.tsx index bd50b4e78a1..01b1c28c40c 100644 --- a/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunSetup.test.tsx +++ b/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunSetup.test.tsx @@ -1,7 +1,10 @@ import * as React from 'react' import { when, resetAllWhenMocks } from 'jest-when' -import { parseAllRequiredModuleModels } from '@opentrons/api-client' +import { + parseAllRequiredModuleModels, + parseLiquidsInLoadOrder, +} from '@opentrons/api-client' import { partialComponentPropsMatcher, renderWithProviders, @@ -76,6 +79,9 @@ const mockUseStoredProtocolAnalysis = useStoredProtocolAnalysis as jest.MockedFu const mockParseAllRequiredModuleModels = parseAllRequiredModuleModels as jest.MockedFunction< typeof parseAllRequiredModuleModels > +const mockParseLiquidsInLoadOrder = parseLiquidsInLoadOrder as jest.MockedFunction< + typeof parseLiquidsInLoadOrder +> const mockSetupLabware = SetupLabware as jest.MockedFunction< typeof SetupLabware > @@ -142,6 +148,7 @@ describe('ProtocolRunSetup', () => { ...MOCK_ROTOCOL_LIQUID_KEY, } as unknown) as ProtocolAnalysisOutput) when(mockParseAllRequiredModuleModels).mockReturnValue([]) + when(mockParseLiquidsInLoadOrder).mockReturnValue([]) when(mockUseRobot) .calledWith(ROBOT_NAME) .mockReturnValue(mockConnectedRobot) diff --git a/app/src/organisms/ProtocolDetails/ProtocolLiquidsDetails.tsx b/app/src/organisms/ProtocolDetails/ProtocolLiquidsDetails.tsx index acc3d6bdc27..a621f0a7b14 100644 --- a/app/src/organisms/ProtocolDetails/ProtocolLiquidsDetails.tsx +++ b/app/src/organisms/ProtocolDetails/ProtocolLiquidsDetails.tsx @@ -45,7 +45,7 @@ export const ProtocolLiquidsDetails = ( overflowY="auto" data-testid="LiquidsDetailsTab" > - {liquids.length > 0 ? ( + {liquidsInLoadOrder.length > 0 ? ( liquidsInLoadOrder?.map((liquid, index) => { return ( diff --git a/app/src/organisms/ProtocolDetails/__tests__/ProtocolLiquidsDetails.test.tsx b/app/src/organisms/ProtocolDetails/__tests__/ProtocolLiquidsDetails.test.tsx index e657317e2e7..48a227b8367 100644 --- a/app/src/organisms/ProtocolDetails/__tests__/ProtocolLiquidsDetails.test.tsx +++ b/app/src/organisms/ProtocolDetails/__tests__/ProtocolLiquidsDetails.test.tsx @@ -63,6 +63,7 @@ describe('ProtocolLiquidsDetails', () => { }) it('renders the correct info for no liquids in the protocol', () => { props.liquids = [] + mockParseLiquidsInLoadOrder.mockReturnValue([]) const [{ getByText, getByLabelText }] = render(props) getByText('No liquids are specified for this protocol') getByLabelText('ProtocolLIquidsDetails_noLiquidsIcon') From fb33407e33d425aee8c9852e92cd348f807d9825 Mon Sep 17 00:00:00 2001 From: ncdiehl11 Date: Mon, 11 Dec 2023 09:46:18 -0500 Subject: [PATCH 2/2] remove unnecessary null check --- app/src/organisms/Devices/ProtocolRun/ProtocolRunSetup.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/organisms/Devices/ProtocolRun/ProtocolRunSetup.tsx b/app/src/organisms/Devices/ProtocolRun/ProtocolRunSetup.tsx index 8414684d584..e1d3180ee2b 100644 --- a/app/src/organisms/Devices/ProtocolRun/ProtocolRunSetup.tsx +++ b/app/src/organisms/Devices/ProtocolRun/ProtocolRunSetup.tsx @@ -144,7 +144,7 @@ export function ProtocolRunSetup({ ? parseLiquidsInLoadOrder(liquids, protocolAnalysis.commands) : [] - const hasLiquids = protocolAnalysis != null && liquidsInLoadOrder.length > 0 + const hasLiquids = liquidsInLoadOrder.length > 0 const hasModules = protocolAnalysis != null && modules.length > 0