Skip to content

Commit

Permalink
fix Protocol Run Header test mocking issue
Browse files Browse the repository at this point in the history
  • Loading branch information
koji committed Mar 1, 2024
1 parent aaaab0b commit 17d47a6
Showing 1 changed file with 22 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,9 @@ import { useNotifyRunQuery } from '../../../../resources/runs/useNotifyRunQuery'

import type { UseQueryResult } from 'react-query'
import type * as ReactRouterDom from 'react-router-dom'
import type { Run } from '@opentrons/api-client'
import type { CompletedProtocolAnalysis } from '@opentrons/shared-data'
import type * as OpentronsSharedData from '@opentrons/shared-data'
import type * as OpentronsComponents from '@opentrons/components'
import type * as OpentronsApiClient from '@opentrons/api-client'

const mockPush = vi.fn()

Expand All @@ -124,8 +123,6 @@ vi.mock('@opentrons/shared-data', async importOriginal => {
const actual = await importOriginal<typeof OpentronsSharedData>()
return {
...actual,
getAllPipetteNames: vi.fn(),
getPipetteNameSpecs: vi.fn(),
getPipetteModelSpecs: vi.fn(),
}
})
Expand Down Expand Up @@ -166,7 +163,7 @@ const mockSettings = {
}
const MOCK_ROTOCOL_LIQUID_KEY = { liquids: [] }

const simpleV6Protocol = (_uncastedSimpleV6Protocol as unknown) as CompletedProtocolAnalysis
const simpleV6Protocol = (_uncastedSimpleV6Protocol as unknown) as OpentronsSharedData.CompletedProtocolAnalysis

const PROTOCOL_DETAILS = {
displayName: PROTOCOL_NAME,
Expand Down Expand Up @@ -301,7 +298,7 @@ describe('ProtocolRunHeader', () => {
.calledWith(RUN_ID, { staleTime: Infinity })
.thenReturn({
data: { data: mockIdleUnstartedRun },
} as UseQueryResult<Run>)
} as UseQueryResult<OpentronsApiClient.Run>)
when(vi.mocked(useProtocolDetailsForRun))
.calledWith(RUN_ID)
.thenReturn(PROTOCOL_DETAILS)
Expand Down Expand Up @@ -343,8 +340,8 @@ describe('ProtocolRunHeader', () => {
...MOCK_ROTOCOL_LIQUID_KEY,
} as any)
vi.mocked(useDeckConfigurationCompatibility).mockReturnValue([])
when(vi.mocked(getIsFixtureMismatch)).thenReturn(false)
when(vi.mocked(useMostRecentRunId)).thenReturn(RUN_ID)
vi.mocked(getIsFixtureMismatch).mockReturnValue(false)
vi.mocked(useMostRecentRunId).mockReturnValue(RUN_ID)
})

afterEach(() => {
Expand Down Expand Up @@ -431,7 +428,7 @@ describe('ProtocolRunHeader', () => {
.calledWith(RUN_ID)
.thenReturn({
data: { data: { ...mockIdleUnstartedRun, current: true } },
} as UseQueryResult<Run>)
} as UseQueryResult<OpentronsApiClient.Run>)
render()
expect(mockCloseCurrentRun).toBeCalled()
expect(mockTrackProtocolRunEvent).toBeCalled()
Expand Down Expand Up @@ -505,7 +502,7 @@ describe('ProtocolRunHeader', () => {
.calledWith(RUN_ID)
.thenReturn({
data: { data: mockRunningRun },
} as UseQueryResult<Run>)
} as UseQueryResult<OpentronsApiClient.Run>)
when(vi.mocked(useRunStatus))
.calledWith(RUN_ID)
.thenReturn(RUN_STATUS_RUNNING)
Expand All @@ -526,7 +523,7 @@ describe('ProtocolRunHeader', () => {
.calledWith(RUN_ID)
.thenReturn({
data: { data: mockRunningRun },
} as UseQueryResult<Run>)
} as UseQueryResult<OpentronsApiClient.Run>)
when(vi.mocked(useRunStatus))
.calledWith(RUN_ID)
.thenReturn(RUN_STATUS_RUNNING)
Expand All @@ -543,7 +540,7 @@ describe('ProtocolRunHeader', () => {
.calledWith(RUN_ID)
.thenReturn({
data: { data: mockPausedRun },
} as UseQueryResult<Run>)
} as UseQueryResult<OpentronsApiClient.Run>)
when(vi.mocked(useRunStatus))
.calledWith(RUN_ID)
.thenReturn(RUN_STATUS_PAUSED)
Expand All @@ -565,7 +562,7 @@ describe('ProtocolRunHeader', () => {
.calledWith(RUN_ID)
.thenReturn({
data: { data: mockPauseRequestedRun },
} as UseQueryResult<Run>)
} as UseQueryResult<OpentronsApiClient.Run>)
when(vi.mocked(useRunStatus))
.calledWith(RUN_ID)
.thenReturn(RUN_STATUS_PAUSE_REQUESTED)
Expand All @@ -583,7 +580,7 @@ describe('ProtocolRunHeader', () => {
.calledWith(RUN_ID)
.thenReturn({
data: { data: mockStopRequestedRun },
} as UseQueryResult<Run>)
} as UseQueryResult<OpentronsApiClient.Run>)
when(vi.mocked(useRunStatus))
.calledWith(RUN_ID)
.thenReturn(RUN_STATUS_STOP_REQUESTED)
Expand All @@ -600,7 +597,7 @@ describe('ProtocolRunHeader', () => {
.calledWith(RUN_ID)
.thenReturn({
data: { data: mockRunningRun },
} as UseQueryResult<Run>)
} as UseQueryResult<OpentronsApiClient.Run>)
when(vi.mocked(useRunStatus))
.calledWith(RUN_ID)
.thenReturn(RUN_STATUS_BLOCKED_BY_OPEN_DOOR)
Expand All @@ -622,7 +619,7 @@ describe('ProtocolRunHeader', () => {
.calledWith(RUN_ID)
.thenReturn({
data: { data: mockStoppedRun },
} as UseQueryResult<Run>)
} as UseQueryResult<OpentronsApiClient.Run>)
when(vi.mocked(useRunStatus))
.calledWith(RUN_ID)
.thenReturn(RUN_STATUS_STOPPED)
Expand All @@ -649,7 +646,7 @@ describe('ProtocolRunHeader', () => {
.calledWith(RUN_ID)
.thenReturn({
data: { data: mockFailedRun },
} as UseQueryResult<Run>)
} as UseQueryResult<OpentronsApiClient.Run>)
when(vi.mocked(useRunStatus))
.calledWith(RUN_ID)
.thenReturn(RUN_STATUS_FAILED)
Expand All @@ -676,7 +673,7 @@ describe('ProtocolRunHeader', () => {
.calledWith(RUN_ID)
.thenReturn({
data: { data: mockSucceededRun },
} as UseQueryResult<Run>)
} as UseQueryResult<OpentronsApiClient.Run>)
when(vi.mocked(useRunStatus))
.calledWith(RUN_ID)
.thenReturn(RUN_STATUS_SUCCEEDED)
Expand Down Expand Up @@ -707,7 +704,7 @@ describe('ProtocolRunHeader', () => {
.calledWith(RUN_ID)
.thenReturn({
data: { data: mockSucceededRun },
} as UseQueryResult<Run>)
} as UseQueryResult<OpentronsApiClient.Run>)
when(vi.mocked(useRunStatus))
.calledWith(RUN_ID)
.thenReturn(RUN_STATUS_SUCCEEDED)
Expand Down Expand Up @@ -742,7 +739,7 @@ describe('ProtocolRunHeader', () => {
.calledWith(RUN_ID)
.thenReturn({
data: { data: mockFailedRun },
} as UseQueryResult<Run>)
} as UseQueryResult<OpentronsApiClient.Run>)
when(vi.mocked(useRunStatus))
.calledWith(RUN_ID)
.thenReturn(RUN_STATUS_FAILED)
Expand All @@ -758,7 +755,7 @@ describe('ProtocolRunHeader', () => {
.calledWith(RUN_ID)
.thenReturn({
data: { data: mockFailedRun },
} as UseQueryResult<Run>)
} as UseQueryResult<OpentronsApiClient.Run>)
when(vi.mocked(useRunStatus))
.calledWith(RUN_ID)
.thenReturn(RUN_STATUS_FAILED)
Expand Down Expand Up @@ -794,7 +791,7 @@ describe('ProtocolRunHeader', () => {
.calledWith(RUN_ID)
.thenReturn({
data: { data: mockSucceededRun },
} as UseQueryResult<Run>)
} as UseQueryResult<OpentronsApiClient.Run>)
when(vi.mocked(useRunStatus))
.calledWith(RUN_ID)
.thenReturn(RUN_STATUS_SUCCEEDED)
Expand Down Expand Up @@ -908,7 +905,7 @@ describe('ProtocolRunHeader', () => {
.calledWith(RUN_ID)
.thenReturn({
data: { data: mockSucceededRun },
} as UseQueryResult<Run>)
} as UseQueryResult<OpentronsApiClient.Run>)
when(vi.mocked(useRunStatus))
.calledWith(RUN_ID)
.thenReturn(RUN_STATUS_SUCCEEDED)
Expand Down Expand Up @@ -965,7 +962,7 @@ describe('ProtocolRunHeader', () => {
status: RUN_STATUS_SUCCEEDED,
},
},
} as UseQueryResult<Run>)
} as UseQueryResult<OpentronsApiClient.Run>)
when(vi.mocked(useRunStatus))
.calledWith(RUN_ID)
.thenReturn(RUN_STATUS_SUCCEEDED)
Expand All @@ -987,7 +984,7 @@ describe('ProtocolRunHeader', () => {
status: RUN_STATUS_IDLE,
},
},
} as UseQueryResult<Run>)
} as UseQueryResult<OpentronsApiClient.Run>)
when(vi.mocked(useRunStatus)).calledWith(RUN_ID).thenReturn(RUN_STATUS_IDLE)

render()
Expand Down

0 comments on commit 17d47a6

Please sign in to comment.