Skip to content

Commit

Permalink
refactor(app): correct door open disabled tooltip logic on run page (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
shlokamin authored Oct 16, 2023
1 parent 791dbe7 commit f3f3e64
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
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 @@ -551,7 +551,11 @@ function ActionButton(props: ActionButtonProps): JSX.Element {
disableReason = t('shared:robot_is_busy')
} else if (isRobotOnWrongVersionOfSoftware) {
disableReason = t('shared:a_software_update_is_available')
} else if (runStatus != null && DISABLED_STATUSES.includes(runStatus)) {
} else if (
isDoorOpen &&
runStatus != null &&
START_RUN_STATUSES.includes(runStatus)
) {
disableReason = t('close_door')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,28 @@ describe('ProtocolRunHeader', () => {
getByText('Stop requested')
})

it('renders a disabled button and when the robot door is open', () => {
when(mockUseRunQuery)
.calledWith(RUN_ID)
.mockReturnValue({
data: { data: mockRunningRun },
} as UseQueryResult<Run>)
when(mockUseRunStatus)
.calledWith(RUN_ID)
.mockReturnValue(RUN_STATUS_BLOCKED_BY_OPEN_DOOR)

const mockOpenDoorStatus = {
data: { status: 'open', doorRequiredClosedForProtocol: true },
}
mockUseDoorQuery.mockReturnValue({ data: mockOpenDoorStatus } as any)

const [{ getByText, getByRole }] = render()

const button = getByRole('button', { name: 'Resume run' })
expect(button).toBeDisabled()
getByText('Close robot door')
})

it('renders a Run Again button and end time when run has stopped and calls trackProtocolRunEvent when run again button clicked', () => {
when(mockUseRunQuery)
.calledWith(RUN_ID)
Expand Down

0 comments on commit f3f3e64

Please sign in to comment.