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

fix(app): properly display no liquids used text in protocol details/setup #14144

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions app/src/organisms/Devices/ProtocolRun/ProtocolRunSetup.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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
ncdiehl11 marked this conversation as resolved.
Show resolved Hide resolved

const hasModules = protocolAnalysis != null && modules.length > 0

const protocolDeckConfig = getSimplestDeckConfigForProtocol(protocolAnalysis)
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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
>
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const ProtocolLiquidsDetails = (
overflowY="auto"
data-testid="LiquidsDetailsTab"
>
{liquids.length > 0 ? (
{liquidsInLoadOrder.length > 0 ? (
liquidsInLoadOrder?.map((liquid, index) => {
return (
<React.Fragment key={liquid.id}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Loading