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): Don't render ProtocolRunHeader TerminalBanner on CurrentRun #14233

Merged
merged 3 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ export function ProtocolRunHeader({
CANCELLABLE_STATUSES.includes(runStatus) ? (
<Banner type="warning">{t('shared:close_robot_door')}</Banner>
) : null}
{isRunCurrent ? (
{mostRecentRunId === runId ? (
<TerminalRunBanner
{...{
runStatus,
Expand Down Expand Up @@ -455,7 +455,7 @@ export function ProtocolRunHeader({
) : null}
{showDropTipWizard &&
pipettesWithTip[0]?.specs != null &&
isRunCurrent ? (
mostRecentRunId === runId ? (
<DropTipWizard
robotType={isFlex ? FLEX_ROBOT_TYPE : OT2_ROBOT_TYPE}
mount={pipettesWithTip[0].mount}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1054,26 +1054,4 @@ describe('ProtocolRunHeader', () => {
expect(queryByText('Tips may be attached.')).not.toBeInTheDocument()
})
})

Copy link
Contributor Author

@mjhuff mjhuff Dec 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is functionally a duplicate of the one above now that we don't tie the drop tip banners to currentRunId, therefore I removed it.

it('does not show the drop tip banner when the run is not over', async () => {
when(mockUseRunQuery)
.calledWith(RUN_ID)
.mockReturnValue({
data: {
data: {
...mockIdleUnstartedRun,
current: false,
status: RUN_STATUS_SUCCEEDED,
},
},
} as UseQueryResult<Run>)
when(mockUseRunStatus)
.calledWith(RUN_ID)
.mockReturnValue(RUN_STATUS_SUCCEEDED)

const [{ queryByText }] = render()
await waitFor(() => {
expect(queryByText('Tips may be attached.')).not.toBeInTheDocument()
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ describe('useMostRecentRunId hook', () => {

const { result } = renderHook(useMostRecentRunId)

expect(result.current).toBeNull()
})
it('should return null if no run data exists', async () => {
when(mockUseAllRunsQuery)
.calledWith()
.mockReturnValue({ data: { data: null } } as any)

const { result } = renderHook(useMostRecentRunId)

expect(result.current).toBeNull()
})
})
5 changes: 3 additions & 2 deletions app/src/organisms/ProtocolUpload/hooks/useMostRecentRunId.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { useAllRunsQuery } from '@opentrons/react-api-client'
import last from 'lodash/last'

export function useMostRecentRunId(): string | null {
const { data: allRuns } = useAllRunsQuery()
return allRuns != null && allRuns.data.length > 0
? allRuns.data[allRuns.data.length - 1].id
return allRuns != null && allRuns.data?.length > 0
? last(allRuns.data)?.id ?? null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

: null
}
Loading