Skip to content

Commit 17d47a6

Browse files
committed
fix Protocol Run Header test mocking issue
1 parent aaaab0b commit 17d47a6

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed

app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunHeader.test.tsx

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,9 @@ import { useNotifyRunQuery } from '../../../../resources/runs/useNotifyRunQuery'
9797

9898
import type { UseQueryResult } from 'react-query'
9999
import type * as ReactRouterDom from 'react-router-dom'
100-
import type { Run } from '@opentrons/api-client'
101-
import type { CompletedProtocolAnalysis } from '@opentrons/shared-data'
102100
import type * as OpentronsSharedData from '@opentrons/shared-data'
103101
import type * as OpentronsComponents from '@opentrons/components'
102+
import type * as OpentronsApiClient from '@opentrons/api-client'
104103

105104
const mockPush = vi.fn()
106105

@@ -124,8 +123,6 @@ vi.mock('@opentrons/shared-data', async importOriginal => {
124123
const actual = await importOriginal<typeof OpentronsSharedData>()
125124
return {
126125
...actual,
127-
getAllPipetteNames: vi.fn(),
128-
getPipetteNameSpecs: vi.fn(),
129126
getPipetteModelSpecs: vi.fn(),
130127
}
131128
})
@@ -166,7 +163,7 @@ const mockSettings = {
166163
}
167164
const MOCK_ROTOCOL_LIQUID_KEY = { liquids: [] }
168165

169-
const simpleV6Protocol = (_uncastedSimpleV6Protocol as unknown) as CompletedProtocolAnalysis
166+
const simpleV6Protocol = (_uncastedSimpleV6Protocol as unknown) as OpentronsSharedData.CompletedProtocolAnalysis
170167

171168
const PROTOCOL_DETAILS = {
172169
displayName: PROTOCOL_NAME,
@@ -301,7 +298,7 @@ describe('ProtocolRunHeader', () => {
301298
.calledWith(RUN_ID, { staleTime: Infinity })
302299
.thenReturn({
303300
data: { data: mockIdleUnstartedRun },
304-
} as UseQueryResult<Run>)
301+
} as UseQueryResult<OpentronsApiClient.Run>)
305302
when(vi.mocked(useProtocolDetailsForRun))
306303
.calledWith(RUN_ID)
307304
.thenReturn(PROTOCOL_DETAILS)
@@ -343,8 +340,8 @@ describe('ProtocolRunHeader', () => {
343340
...MOCK_ROTOCOL_LIQUID_KEY,
344341
} as any)
345342
vi.mocked(useDeckConfigurationCompatibility).mockReturnValue([])
346-
when(vi.mocked(getIsFixtureMismatch)).thenReturn(false)
347-
when(vi.mocked(useMostRecentRunId)).thenReturn(RUN_ID)
343+
vi.mocked(getIsFixtureMismatch).mockReturnValue(false)
344+
vi.mocked(useMostRecentRunId).mockReturnValue(RUN_ID)
348345
})
349346

350347
afterEach(() => {
@@ -431,7 +428,7 @@ describe('ProtocolRunHeader', () => {
431428
.calledWith(RUN_ID)
432429
.thenReturn({
433430
data: { data: { ...mockIdleUnstartedRun, current: true } },
434-
} as UseQueryResult<Run>)
431+
} as UseQueryResult<OpentronsApiClient.Run>)
435432
render()
436433
expect(mockCloseCurrentRun).toBeCalled()
437434
expect(mockTrackProtocolRunEvent).toBeCalled()
@@ -505,7 +502,7 @@ describe('ProtocolRunHeader', () => {
505502
.calledWith(RUN_ID)
506503
.thenReturn({
507504
data: { data: mockRunningRun },
508-
} as UseQueryResult<Run>)
505+
} as UseQueryResult<OpentronsApiClient.Run>)
509506
when(vi.mocked(useRunStatus))
510507
.calledWith(RUN_ID)
511508
.thenReturn(RUN_STATUS_RUNNING)
@@ -526,7 +523,7 @@ describe('ProtocolRunHeader', () => {
526523
.calledWith(RUN_ID)
527524
.thenReturn({
528525
data: { data: mockRunningRun },
529-
} as UseQueryResult<Run>)
526+
} as UseQueryResult<OpentronsApiClient.Run>)
530527
when(vi.mocked(useRunStatus))
531528
.calledWith(RUN_ID)
532529
.thenReturn(RUN_STATUS_RUNNING)
@@ -543,7 +540,7 @@ describe('ProtocolRunHeader', () => {
543540
.calledWith(RUN_ID)
544541
.thenReturn({
545542
data: { data: mockPausedRun },
546-
} as UseQueryResult<Run>)
543+
} as UseQueryResult<OpentronsApiClient.Run>)
547544
when(vi.mocked(useRunStatus))
548545
.calledWith(RUN_ID)
549546
.thenReturn(RUN_STATUS_PAUSED)
@@ -565,7 +562,7 @@ describe('ProtocolRunHeader', () => {
565562
.calledWith(RUN_ID)
566563
.thenReturn({
567564
data: { data: mockPauseRequestedRun },
568-
} as UseQueryResult<Run>)
565+
} as UseQueryResult<OpentronsApiClient.Run>)
569566
when(vi.mocked(useRunStatus))
570567
.calledWith(RUN_ID)
571568
.thenReturn(RUN_STATUS_PAUSE_REQUESTED)
@@ -583,7 +580,7 @@ describe('ProtocolRunHeader', () => {
583580
.calledWith(RUN_ID)
584581
.thenReturn({
585582
data: { data: mockStopRequestedRun },
586-
} as UseQueryResult<Run>)
583+
} as UseQueryResult<OpentronsApiClient.Run>)
587584
when(vi.mocked(useRunStatus))
588585
.calledWith(RUN_ID)
589586
.thenReturn(RUN_STATUS_STOP_REQUESTED)
@@ -600,7 +597,7 @@ describe('ProtocolRunHeader', () => {
600597
.calledWith(RUN_ID)
601598
.thenReturn({
602599
data: { data: mockRunningRun },
603-
} as UseQueryResult<Run>)
600+
} as UseQueryResult<OpentronsApiClient.Run>)
604601
when(vi.mocked(useRunStatus))
605602
.calledWith(RUN_ID)
606603
.thenReturn(RUN_STATUS_BLOCKED_BY_OPEN_DOOR)
@@ -622,7 +619,7 @@ describe('ProtocolRunHeader', () => {
622619
.calledWith(RUN_ID)
623620
.thenReturn({
624621
data: { data: mockStoppedRun },
625-
} as UseQueryResult<Run>)
622+
} as UseQueryResult<OpentronsApiClient.Run>)
626623
when(vi.mocked(useRunStatus))
627624
.calledWith(RUN_ID)
628625
.thenReturn(RUN_STATUS_STOPPED)
@@ -649,7 +646,7 @@ describe('ProtocolRunHeader', () => {
649646
.calledWith(RUN_ID)
650647
.thenReturn({
651648
data: { data: mockFailedRun },
652-
} as UseQueryResult<Run>)
649+
} as UseQueryResult<OpentronsApiClient.Run>)
653650
when(vi.mocked(useRunStatus))
654651
.calledWith(RUN_ID)
655652
.thenReturn(RUN_STATUS_FAILED)
@@ -676,7 +673,7 @@ describe('ProtocolRunHeader', () => {
676673
.calledWith(RUN_ID)
677674
.thenReturn({
678675
data: { data: mockSucceededRun },
679-
} as UseQueryResult<Run>)
676+
} as UseQueryResult<OpentronsApiClient.Run>)
680677
when(vi.mocked(useRunStatus))
681678
.calledWith(RUN_ID)
682679
.thenReturn(RUN_STATUS_SUCCEEDED)
@@ -707,7 +704,7 @@ describe('ProtocolRunHeader', () => {
707704
.calledWith(RUN_ID)
708705
.thenReturn({
709706
data: { data: mockSucceededRun },
710-
} as UseQueryResult<Run>)
707+
} as UseQueryResult<OpentronsApiClient.Run>)
711708
when(vi.mocked(useRunStatus))
712709
.calledWith(RUN_ID)
713710
.thenReturn(RUN_STATUS_SUCCEEDED)
@@ -742,7 +739,7 @@ describe('ProtocolRunHeader', () => {
742739
.calledWith(RUN_ID)
743740
.thenReturn({
744741
data: { data: mockFailedRun },
745-
} as UseQueryResult<Run>)
742+
} as UseQueryResult<OpentronsApiClient.Run>)
746743
when(vi.mocked(useRunStatus))
747744
.calledWith(RUN_ID)
748745
.thenReturn(RUN_STATUS_FAILED)
@@ -758,7 +755,7 @@ describe('ProtocolRunHeader', () => {
758755
.calledWith(RUN_ID)
759756
.thenReturn({
760757
data: { data: mockFailedRun },
761-
} as UseQueryResult<Run>)
758+
} as UseQueryResult<OpentronsApiClient.Run>)
762759
when(vi.mocked(useRunStatus))
763760
.calledWith(RUN_ID)
764761
.thenReturn(RUN_STATUS_FAILED)
@@ -794,7 +791,7 @@ describe('ProtocolRunHeader', () => {
794791
.calledWith(RUN_ID)
795792
.thenReturn({
796793
data: { data: mockSucceededRun },
797-
} as UseQueryResult<Run>)
794+
} as UseQueryResult<OpentronsApiClient.Run>)
798795
when(vi.mocked(useRunStatus))
799796
.calledWith(RUN_ID)
800797
.thenReturn(RUN_STATUS_SUCCEEDED)
@@ -908,7 +905,7 @@ describe('ProtocolRunHeader', () => {
908905
.calledWith(RUN_ID)
909906
.thenReturn({
910907
data: { data: mockSucceededRun },
911-
} as UseQueryResult<Run>)
908+
} as UseQueryResult<OpentronsApiClient.Run>)
912909
when(vi.mocked(useRunStatus))
913910
.calledWith(RUN_ID)
914911
.thenReturn(RUN_STATUS_SUCCEEDED)
@@ -965,7 +962,7 @@ describe('ProtocolRunHeader', () => {
965962
status: RUN_STATUS_SUCCEEDED,
966963
},
967964
},
968-
} as UseQueryResult<Run>)
965+
} as UseQueryResult<OpentronsApiClient.Run>)
969966
when(vi.mocked(useRunStatus))
970967
.calledWith(RUN_ID)
971968
.thenReturn(RUN_STATUS_SUCCEEDED)
@@ -987,7 +984,7 @@ describe('ProtocolRunHeader', () => {
987984
status: RUN_STATUS_IDLE,
988985
},
989986
},
990-
} as UseQueryResult<Run>)
987+
} as UseQueryResult<OpentronsApiClient.Run>)
991988
when(vi.mocked(useRunStatus)).calledWith(RUN_ID).thenReturn(RUN_STATUS_IDLE)
992989

993990
render()

0 commit comments

Comments
 (0)