From f3f3e64858f1c89b548509fc5d9bb9f78d6dca1c Mon Sep 17 00:00:00 2001 From: Shlok Amin Date: Mon, 16 Oct 2023 15:51:01 -0400 Subject: [PATCH] refactor(app): correct door open disabled tooltip logic on run page (#13795) fixes RQA-1705 --- .../Devices/ProtocolRun/ProtocolRunHeader.tsx | 6 ++++- .../__tests__/ProtocolRunHeader.test.tsx | 22 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx b/app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx index f8eb4b53d34..658e121ea8b 100644 --- a/app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx +++ b/app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx @@ -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') } diff --git a/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunHeader.test.tsx b/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunHeader.test.tsx index 4e3cc7afd7e..c6a638b20e8 100644 --- a/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunHeader.test.tsx +++ b/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunHeader.test.tsx @@ -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) + 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)