diff --git a/app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx b/app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx index 5c527bd053b..556d95f382d 100644 --- a/app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx +++ b/app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx @@ -46,6 +46,7 @@ import { } from '@opentrons/components' import { getRobotUpdateDisplayInfo } from '../../../redux/robot-update' +import { getRobotSettings } from '../../../redux/robot-settings' import { ProtocolAnalysisErrorBanner } from './ProtocolAnalysisErrorBanner' import { ProtocolAnalysisErrorModal } from './ProtocolAnalysisErrorModal' import { Banner } from '../../../atoms/Banner' @@ -83,6 +84,7 @@ import { useIsRobotViewable, useTrackProtocolRunEvent, useRobotAnalyticsData, + useIsOT3, } from '../hooks' import { formatTimestamp } from '../utils' import { RunTimer } from './RunTimer' @@ -140,12 +142,25 @@ export function ProtocolRunHeader({ runRecord?.data.errors?.[0] != null ? getHighestPriorityError(runRecord?.data?.errors) : null + + const robotSettings = useSelector((state: State) => + getRobotSettings(state, robotName) + ) + const doorSafetySetting = robotSettings.find( + setting => setting.id === 'enableDoorSafetySwitch' + ) + const isOT3 = useIsOT3(robotName) const { data: doorStatus } = useDoorQuery({ refetchInterval: EQUIPMENT_POLL_MS, }) - const isDoorOpen = - doorStatus?.data.status === 'open' && - doorStatus?.data.doorRequiredClosedForProtocol + let isDoorOpen = false + if (isOT3) { + isDoorOpen = doorStatus?.data.status === 'open' + } else if (!isOT3 && Boolean(doorSafetySetting?.value)) { + isDoorOpen = doorStatus?.data.status === 'open' + } else { + isDoorOpen = false + } React.useEffect(() => { if (protocolData != null && !isRobotViewable) { diff --git a/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunHeader.test.tsx b/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunHeader.test.tsx index 31fa9c930ad..0e52d62c811 100644 --- a/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunHeader.test.tsx +++ b/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunHeader.test.tsx @@ -58,6 +58,7 @@ import { } from '../../../../redux/analytics' import { getRobotUpdateDisplayInfo } from '../../../../redux/robot-update' import { getIsHeaterShakerAttached } from '../../../../redux/config' +import { getRobotSettings } from '../../../../redux/robot-settings' import { useProtocolDetailsForRun, @@ -111,6 +112,7 @@ jest.mock('../../../../redux/analytics') jest.mock('../../../../redux/config') jest.mock('../RunFailedModal') jest.mock('../../../../redux/robot-update/selectors') +jest.mock('../../../../redux/robot-settings/selectors') const mockGetIsHeaterShakerAttached = getIsHeaterShakerAttached as jest.MockedFunction< typeof getIsHeaterShakerAttached @@ -192,6 +194,9 @@ const mockUseIsOT3 = useIsOT3 as jest.MockedFunction const mockUseDoorQuery = useDoorQuery as jest.MockedFunction< typeof useDoorQuery > +const mockGetRobotSettings = getRobotSettings as jest.MockedFunction< + typeof getRobotSettings +> const ROBOT_NAME = 'otie' const RUN_ID = '95e67900-bc9f-4fbf-92c6-cc4d7226a51b' @@ -199,6 +204,13 @@ const CREATED_AT = '03/03/2022 19:08:49' const STARTED_AT = '2022-03-03T19:09:40.620530+00:00' const COMPLETED_AT = '2022-03-03T19:39:53.620530+00:00' const PROTOCOL_NAME = 'A Protocol for Otie' +const mockSettings = { + id: 'enableDoorSafetySwitch', + title: 'Enable Door Safety Switch', + description: '', + value: true, + restart_required: false, +} const simpleV6Protocol = (_uncastedSimpleV6Protocol as unknown) as CompletedProtocolAnalysis @@ -351,10 +363,11 @@ describe('ProtocolRunHeader', () => { when(mockUseRunCalibrationStatus) .calledWith(ROBOT_NAME, RUN_ID) .mockReturnValue({ complete: true }) - mockUseIsOT3.mockReturnValue(true) + when(mockUseIsOT3).calledWith(ROBOT_NAME).mockReturnValue(true) mockRunFailedModal.mockReturnValue(
mock RunFailedModal
) mockUseEstopQuery.mockReturnValue({ data: mockEstopStatus } as any) mockUseDoorQuery.mockReturnValue({ data: mockDoorStatus } as any) + mockGetRobotSettings.mockReturnValue([mockSettings]) }) afterEach(() => { @@ -849,7 +862,17 @@ describe('ProtocolRunHeader', () => { getByLabelText('ot-spinner') }) - it('renders banner when the robot door is open', () => { + it('renders door close banner when the robot door is open', () => { + const mockOpenDoorStatus = { + data: { status: 'open', doorRequiredClosedForProtocol: true }, + } + mockUseDoorQuery.mockReturnValue({ data: mockOpenDoorStatus } as any) + const [{ getByText }] = render() + getByText('Close the robot door before starting the run.') + }) + + it('should render door close banner when door is open and enabled safety door switch is on - OT-2', () => { + when(mockUseIsOT3).calledWith(ROBOT_NAME).mockReturnValue(false) const mockOpenDoorStatus = { data: { status: 'open', doorRequiredClosedForProtocol: true }, } @@ -857,4 +880,18 @@ describe('ProtocolRunHeader', () => { const [{ getByText }] = render() getByText('Close the robot door before starting the run.') }) + + it('should not render door close banner when door is open and enabled safety door switch is off - OT-2', () => { + when(mockUseIsOT3).calledWith(ROBOT_NAME).mockReturnValue(false) + const mockOffSettings = { ...mockSettings, value: false } + mockGetRobotSettings.mockReturnValue([mockOffSettings]) + const mockOpenDoorStatus = { + data: { status: 'open', doorRequiredClosedForProtocol: true }, + } + mockUseDoorQuery.mockReturnValue({ data: mockOpenDoorStatus } as any) + const [{ queryByText }] = render() + expect( + queryByText('Close the robot door before starting the run.') + ).not.toBeInTheDocument() + }) })