Skip to content

Commit

Permalink
fix(app): disable 'Run a protocol' robot overflow menu item if robot …
Browse files Browse the repository at this point in the history
…is busy (#14916)

closes RQA-2570
  • Loading branch information
ncdiehl11 authored Apr 16, 2024
1 parent 829aa79 commit df1d203
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
30 changes: 16 additions & 14 deletions app/src/organisms/Devices/RobotOverflowMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,27 @@ export function RobotOverflowMenu(props: RobotOverflowMenuProps): JSX.Element {
if (robot.status === CONNECTABLE && runId == null) {
menuItems = (
<>
{!isRobotBusy ? (
<MenuItem
{...targetProps}
onClick={handleClickRun}
disabled={isRobotOnWrongVersionOfSoftware}
data-testid={`RobotOverflowMenu_${robot.name}_runProtocol`}
css={css`
border-radius: ${BORDERS.borderRadius8} ${BORDERS.borderRadius8} 0
0;
`}
>
{t('run_a_protocol')}
</MenuItem>
) : null}
<MenuItem
{...targetProps}
onClick={handleClickRun}
disabled={isRobotOnWrongVersionOfSoftware || isRobotBusy}
data-testid={`RobotOverflowMenu_${robot.name}_runProtocol`}
css={css`
border-radius: ${BORDERS.borderRadius8} ${BORDERS.borderRadius8} 0 0;
`}
>
{t('run_a_protocol')}
</MenuItem>
{isRobotOnWrongVersionOfSoftware && (
<Tooltip tooltipProps={tooltipProps} whiteSpace="normal">
{t('shared:a_software_update_is_available')}
</Tooltip>
)}
{!isRobotOnWrongVersionOfSoftware && isRobotBusy && (
<Tooltip tooltipProps={tooltipProps} whiteSpace="normal">
{t('shared:robot_is_busy')}
</Tooltip>
)}
<Divider marginY="0" />
<MenuItem
to={`/devices/${robot.name}/robot-settings`}
Expand Down
13 changes: 4 additions & 9 deletions app/src/organisms/Devices/__tests__/RobotOverflowMenu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ vi.mock('../../../redux/robot-update/selectors')
vi.mock('../../ProtocolUpload/hooks')
vi.mock('../../ChooseProtocolSlideout')
vi.mock('../hooks')
vi.mock('../../../resources/devices/hooks/useIsEstopNotDisengaged')

const render = (props: React.ComponentProps<typeof RobotOverflowMenu>) => {
return renderWithProviders(
Expand Down Expand Up @@ -85,19 +86,13 @@ describe('RobotOverflowMenu', () => {
expect(run).toBeDisabled()
})

it('should only render robot settings when e-stop is pressed or disconnected', () => {
it('disables the run a protocol menu item if robot is busy', () => {
vi.mocked(useCurrentRunId).mockReturnValue(null)
vi.mocked(getRobotUpdateDisplayInfo).mockReturnValue({
autoUpdateAction: 'upgrade',
autoUpdateDisabledReason: null,
updateFromFileDisabledReason: null,
})

vi.mocked(useIsRobotBusy).mockReturnValue(true)
render(props)
const btn = screen.getByLabelText('RobotOverflowMenu_button')
fireEvent.click(btn)
expect(screen.queryByText('Run a protocol')).not.toBeInTheDocument()
screen.getByText('Robot settings')
const run = screen.getByText('Run a protocol')
expect(run).toBeDisabled()
})
})

0 comments on commit df1d203

Please sign in to comment.