Skip to content

Commit

Permalink
fix(app): fix module calibration odd display (#13782)
Browse files Browse the repository at this point in the history
  • Loading branch information
smb2268 authored Oct 13, 2023
1 parent 326486a commit 0ebb492
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ export function useModuleCalibrationStatus(
const moduleData = moduleInfoKeys.map(
key => moduleRenderInfoForProtocolById[key]
)
if (moduleData.some(m => m.attachedModuleMatch?.moduleOffset == null)) {
if (
moduleData.some(
m => m.attachedModuleMatch?.moduleOffset?.last_modified == null
)
) {
return { complete: false, reason: 'calibrate_module_failure_reason' }
} else {
return { complete: true }
Expand Down
1 change: 0 additions & 1 deletion app/src/organisms/ProtocolSetupModules/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ function RenderModuleStatus({

if (
isModuleReady &&
calibrationStatus.complete &&
module.attachedModuleMatch?.moduleOffset?.last_modified != null
) {
moduleStatus = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import {
useAttachedModules,
useLPCDisabledReason,
useRunCreatedAtTimestamp,
useModuleCalibrationStatus,
} from '../../../../organisms/Devices/hooks'
import { getLocalRobot } from '../../../../redux/discovery'
import { useMostRecentCompletedAnalysis } from '../../../../organisms/LabwarePositionCheck/useMostRecentCompletedAnalysis'
import { ProtocolSetupLiquids } from '../../../../organisms/ProtocolSetupLiquids'
import { getProtocolModulesInfo } from '../../../../organisms/Devices/ProtocolRun/utils/getProtocolModulesInfo'
Expand Down Expand Up @@ -71,6 +73,7 @@ jest.mock('../../../../organisms/RunTimeControl/hooks')
jest.mock('../../../../organisms/ProtocolSetupLiquids')
jest.mock('../../../../organisms/ModuleCard/hooks')
jest.mock('../../../../redux/config')
jest.mock('../../../../redux/discovery/selectors')
jest.mock('../ConfirmAttachedModal')
jest.mock('../../../../organisms/ToasterOven')

Expand Down Expand Up @@ -133,6 +136,12 @@ const mockUseDoorQuery = useDoorQuery as jest.MockedFunction<
typeof useDoorQuery
>
const mockUseToaster = useToaster as jest.MockedFunction<typeof useToaster>
const mockUseModuleCalibrationStatus = useModuleCalibrationStatus as jest.MockedFunction<
typeof useModuleCalibrationStatus
>
const mockGetLocalRobot = getLocalRobot as jest.MockedFunction<
typeof getLocalRobot
>

const render = (path = '/') => {
return renderWithProviders(
Expand Down Expand Up @@ -215,6 +224,8 @@ describe('ProtocolSetup', () => {
mockConfirmCancelRunModal.mockReturnValue(
<div>Mock ConfirmCancelRunModal</div>
)
mockUseModuleCalibrationStatus.mockReturnValue({ complete: true })
mockGetLocalRobot.mockReturnValue({ name: '123' } as any)
when(mockUseRunControls)
.calledWith(RUN_ID)
.mockReturnValue({
Expand Down
15 changes: 9 additions & 6 deletions app/src/pages/OnDeviceDisplay/ProtocolSetup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { ODD_FOCUS_VISIBLE } from '../../../atoms/buttons/constants'
import {
useAttachedModules,
useLPCDisabledReason,
useModuleCalibrationStatus,
} from '../../../organisms/Devices/hooks'
import { useMostRecentCompletedAnalysis } from '../../../organisms/LabwarePositionCheck/useMostRecentCompletedAnalysis'
import { getProtocolModulesInfo } from '../../../organisms/Devices/ProtocolRun/utils/getProtocolModulesInfo'
Expand All @@ -66,7 +67,7 @@ import {
import { useToaster } from '../../../organisms/ToasterOven'
import { useIsHeaterShakerInProtocol } from '../../../organisms/ModuleCard/hooks'
import { getLabwareSetupItemGroups } from '../../Protocols/utils'
import { ROBOT_MODEL_OT3 } from '../../../redux/discovery'
import { ROBOT_MODEL_OT3, getLocalRobot } from '../../../redux/discovery'
import {
useTrackEvent,
ANALYTICS_PROTOCOL_PROCEED_TO_RUN,
Expand Down Expand Up @@ -336,6 +337,8 @@ function PrepareToRun({
const { t, i18n } = useTranslation(['protocol_setup', 'shared'])
const history = useHistory()
const { makeSnackbar } = useToaster()
const localRobot = useSelector(getLocalRobot)
const robotName = localRobot?.name != null ? localRobot.name : 'no name'

// Watch for scrolling to toggle dropshadow
const scrollRef = React.useRef<HTMLDivElement>(null)
Expand Down Expand Up @@ -399,9 +402,7 @@ function PrepareToRun({
hasMissingModulesForOdd: isMissingModules,
hasMissingCalForOdd: !areInstrumentsReady,
})
const requiredCalibration = attachedModules.some(
module => module.moduleOffset?.last_modified == null
)
const moduleCalibrationStatus = useModuleCalibrationStatus(robotName, runId)

const [
showConfirmCancelModal,
Expand All @@ -426,7 +427,9 @@ function PrepareToRun({
const instrumentsStatus = areInstrumentsReady ? 'ready' : 'not ready'

const modulesStatus =
isMissingModules || requiredCalibration ? 'not ready' : 'ready'
isMissingModules || !moduleCalibrationStatus.complete
? 'not ready'
: 'ready'

const isReadyToRun = areInstrumentsReady && !isMissingModules

Expand Down Expand Up @@ -477,7 +480,7 @@ function PrepareToRun({
const modulesDetail = (): string => {
if (isMissingModules) {
return missingModulesText
} else if (requiredCalibration) {
} else if (!moduleCalibrationStatus.complete) {
return t('calibration_required')
} else {
return connectedModulesText
Expand Down

0 comments on commit 0ebb492

Please sign in to comment.