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): disable 'Run a protocol' robot overflow menu item if robot is busy #14916

Merged
merged 1 commit into from
Apr 16, 2024
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
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()
})
})
Loading