Skip to content

Commit 6391b5e

Browse files
committed
update the devices page robotcard
1 parent e6186c5 commit 6391b5e

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

app/src/organisms/Devices/RobotCard.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ import { useIsFlex } from './hooks'
4141
import { ReachableBanner } from './ReachableBanner'
4242
import { RobotOverflowMenu } from './RobotOverflowMenu'
4343
import { RobotStatusHeader } from './RobotStatusHeader'
44+
import {
45+
ErrorRecoveryBanner,
46+
useErrorRecoveryBanner,
47+
} from '../ErrorRecoveryBanner'
4448

4549
import type { GripperData } from '@opentrons/api-client'
4650
import type { GripperModel } from '@opentrons/shared-data'
@@ -59,6 +63,8 @@ export function RobotCard(props: RobotCardProps): JSX.Element | null {
5963
getRobotModelByName(state, robotName)
6064
)
6165

66+
const { showRecoveryBanner, recoveryIntent } = useErrorRecoveryBanner()
67+
6268
return robot != null ? (
6369
<Flex
6470
alignItems={ALIGN_START}
@@ -87,6 +93,12 @@ export function RobotCard(props: RobotCardProps): JSX.Element | null {
8793
>
8894
<UpdateRobotBanner robot={robot} marginRight={SPACING.spacing24} />
8995
<ReachableBanner robot={robot} />
96+
{showRecoveryBanner ? (
97+
<ErrorRecoveryBanner
98+
recoveryIntent={recoveryIntent}
99+
marginRight={SPACING.spacing24}
100+
/>
101+
) : null}
90102
<Flex flexDirection={DIRECTION_COLUMN} gridGap={SPACING.spacing16}>
91103
<RobotStatusHeader
92104
local={local}

app/src/organisms/Devices/__tests__/RobotCard.test.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ import { UpdateRobotBanner } from '../../UpdateRobotBanner'
3131
import { RobotOverflowMenu } from '../RobotOverflowMenu'
3232
import { RobotStatusHeader } from '../RobotStatusHeader'
3333
import { RobotCard } from '../RobotCard'
34+
import {
35+
ErrorRecoveryBanner,
36+
useErrorRecoveryBanner,
37+
} from '../../ErrorRecoveryBanner'
3438

3539
import type { State } from '../../../redux/types'
3640

@@ -41,6 +45,7 @@ vi.mock('../../UpdateRobotBanner')
4145
vi.mock('../../../redux/config')
4246
vi.mock('../RobotOverflowMenu')
4347
vi.mock('../RobotStatusHeader')
48+
vi.mock('../../ErrorRecoveryBanner')
4449

4550
const OT2_PNG_FILE_NAME = '/app/src/assets/images/OT2-R_HERO.png'
4651
const FLEX_PNG_FILE_NAME = '/app/src/assets/images/FLEX.png'
@@ -127,6 +132,13 @@ describe('RobotCard', () => {
127132
when(getRobotModelByName)
128133
.calledWith(MOCK_STATE, mockConnectableRobot.name)
129134
.thenReturn('OT-2')
135+
vi.mocked(ErrorRecoveryBanner).mockReturnValue(
136+
<div>MOCK_RECOVERY_BANNER</div>
137+
)
138+
vi.mocked(useErrorRecoveryBanner).mockReturnValue({
139+
showRecoveryBanner: false,
140+
recoveryIntent: 'recovering',
141+
})
130142
})
131143

132144
it('renders an OT-2 image when robot model is OT-2', () => {
@@ -161,4 +173,15 @@ describe('RobotCard', () => {
161173
render(props)
162174
screen.getByText('Mock RobotStatusHeader')
163175
})
176+
177+
it('renders the error recovery banner when another user is performing error recovery', () => {
178+
vi.mocked(useErrorRecoveryBanner).mockReturnValue({
179+
showRecoveryBanner: true,
180+
recoveryIntent: 'recovering',
181+
})
182+
183+
render(props)
184+
185+
screen.getByText('MOCK_RECOVERY_BANNER')
186+
})
164187
})

0 commit comments

Comments
 (0)