Skip to content

Commit

Permalink
fix(app): remove protocol name link when protocol not stored (#16038)
Browse files Browse the repository at this point in the history
removes the desktop protocol run setup link to protocol details when the
protocol is not stored locally. this changes the previous behavior that
redirected the link to the protocol list page.

closes RQA-2955
  • Loading branch information
brenthagen authored Aug 19, 2024
1 parent 243633c commit b3389fc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
6 changes: 5 additions & 1 deletion app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import {
ANALYTICS_PROTOCOL_RUN_ACTION,
} from '../../../redux/analytics'
import { getIsHeaterShakerAttached } from '../../../redux/config'
import { getStoredProtocol } from '../../../redux/protocol-storage'
import { Tooltip } from '../../../atoms/Tooltip'
import { useCloseCurrentRun } from '../../ProtocolUpload/hooks'
import { ConfirmCancelModal } from '../../RunDetails/ConfirmCancelModal'
Expand Down Expand Up @@ -158,6 +159,9 @@ export function ProtocolRunHeader({
protocolKey,
isProtocolAnalyzing,
} = useProtocolDetailsForRun(runId)
const storedProtocol = useSelector((state: State) =>
getStoredProtocol(state, protocolKey)
)
const { reportRecoveredRunResult } = useRecoveryAnalytics()

const { trackProtocolRunEvent } = useTrackProtocolRunEvent(runId, robotName)
Expand Down Expand Up @@ -390,7 +394,7 @@ export function ProtocolRunHeader({
/>
)}
<Flex>
{protocolKey != null ? (
{storedProtocol != null ? (
<Link to={`/protocols/${protocolKey}`}>
<LegacyStyledText
as="h2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ import { mockConnectableRobot } from '../../../../redux/discovery/__fixtures__'
import { getRobotUpdateDisplayInfo } from '../../../../redux/robot-update'
import { getIsHeaterShakerAttached } from '../../../../redux/config'
import { getRobotSettings } from '../../../../redux/robot-settings'
import { getStoredProtocol } from '../../../../redux/protocol-storage'
import { storedProtocolData as storedProtocolDataFixture } from '../../../../redux/protocol-storage/__fixtures__'
import {
useProtocolDetailsForRun,
useProtocolAnalysisErrors,
Expand Down Expand Up @@ -107,6 +109,7 @@ import type { Mock } from 'vitest'
import type * as OpentronsSharedData from '@opentrons/shared-data'
import type * as OpentronsComponents from '@opentrons/components'
import type * as OpentronsApiClient from '@opentrons/api-client'
import type { State } from '../../../../redux/types'

const mockNavigate = vi.fn()

Expand Down Expand Up @@ -145,6 +148,7 @@ vi.mock('../../../ModuleCard/hooks')
vi.mock('../../../RunProgressMeter')
vi.mock('../../../../redux/analytics')
vi.mock('../../../../redux/config')
vi.mock('../../../../redux/protocol-storage')
vi.mock('../RunFailedModal')
vi.mock('../../../../redux/robot-update/selectors')
vi.mock('../../../../redux/robot-settings/selectors')
Expand All @@ -164,6 +168,7 @@ const CREATED_AT = '03/03/2022 19:08:49'
const STARTED_AT = '2022-03-03T19:09:40.620530+00:00'
const COMPLETED_AT = '2022-03-03T19:39:53.620530+00:00'
const PROTOCOL_NAME = 'A Protocol for Otie'
const PROTOCOL_KEY = 'fakeProtocolKey'
const mockSettings = {
id: 'enableDoorSafetySwitch',
title: 'Enable Door Safety Switch',
Expand All @@ -179,7 +184,7 @@ const simpleV6Protocol = (_uncastedSimpleV6Protocol as unknown) as OpentronsShar
const PROTOCOL_DETAILS = {
displayName: PROTOCOL_NAME,
protocolData: simpleV6Protocol,
protocolKey: 'fakeProtocolKey',
protocolKey: PROTOCOL_KEY,
isProtocolAnalyzing: false,
robotType: 'OT-2 Standard' as const,
}
Expand Down Expand Up @@ -414,6 +419,9 @@ describe('ProtocolRunHeader', () => {
vi.mocked(DropTipWizardFlows).mockReturnValue(
<div>MOCK_DROP_TIP_WIZARD_FLOWS</div>
)
when(getStoredProtocol)
.calledWith({} as State, PROTOCOL_KEY)
.thenReturn(storedProtocolDataFixture)
})

afterEach(() => {
Expand Down Expand Up @@ -453,6 +461,15 @@ describe('ProtocolRunHeader', () => {
).toBeNull()
})

it('does not render link to protocol detail page if stored protocol is absent', () => {
vi.mocked(getStoredProtocol).mockReturnValue(null)
render()

expect(
screen.queryByRole('link', { name: 'A Protocol for Otie' })
).toBeNull()
})

it('renders a disabled "Analyzing on robot" button if robot-side analysis is not complete', () => {
when(vi.mocked(useProtocolDetailsForRun)).calledWith(RUN_ID).thenReturn({
displayName: null,
Expand Down
2 changes: 1 addition & 1 deletion app/src/redux/protocol-storage/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const getStoredProtocols: (

export const getStoredProtocol: (
state: State,
protocolKey?: string
protocolKey?: string | null
) => StoredProtocolData | null = (state, protocolKey) =>
protocolKey != null
? state.protocolStorage.filesByProtocolKey[protocolKey] ?? null
Expand Down

0 comments on commit b3389fc

Please sign in to comment.