Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ncdiehl11 committed Oct 26, 2023
1 parent bd7d93f commit c063297
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react'
import { Route } from 'react-router'
import { MemoryRouter } from 'react-router-dom'
import { when, resetAllWhenMocks } from 'jest-when'
import { UseQueryResult } from 'react-query'

import { RUN_STATUS_IDLE } from '@opentrons/api-client'
import {
Expand All @@ -10,11 +11,15 @@ import {
useRunQuery,
useProtocolQuery,
useDoorQuery,
useModulesQuery,
useDeckConfigurationQuery,
} from '@opentrons/react-api-client'
import { renderWithProviders } from '@opentrons/components'
import { mockHeaterShaker } from '../../../../redux/modules/__fixtures__'
import {
FLEX_ROBOT_TYPE,
getDeckDefFromRobotType,
STAGING_AREA_LOAD_NAME,
} from '@opentrons/shared-data'
import ot3StandardDeckDef from '@opentrons/shared-data/deck/definitions/3/ot3_standard.json'

Expand Down Expand Up @@ -46,7 +51,11 @@ import { ConfirmAttachedModal } from '../ConfirmAttachedModal'
import { useFeatureFlag } from '../../../../redux/config'
import { ProtocolSetup } from '..'

import type { CompletedProtocolAnalysis } from '@opentrons/shared-data'
import type {
DeckConfiguration,
CompletedProtocolAnalysis,
Fixture,
} from '@opentrons/shared-data'

// Mock IntersectionObserver
class IntersectionObserver {
Expand Down Expand Up @@ -143,6 +152,12 @@ const mockConfirmAttachedModal = ConfirmAttachedModal as jest.MockedFunction<
const mockUseDoorQuery = useDoorQuery as jest.MockedFunction<
typeof useDoorQuery
>
const mockUseModulesQuery = useModulesQuery as jest.MockedFunction<
typeof useModulesQuery
>
const mockUseDeckConfigurationQuery = useDeckConfigurationQuery as jest.MockedFunction<
typeof useDeckConfigurationQuery
>
const mockUseToaster = useToaster as jest.MockedFunction<typeof useToaster>
const mockUseFeatureFlag = useFeatureFlag as jest.MockedFunction<
typeof useFeatureFlag
Expand Down Expand Up @@ -219,6 +234,12 @@ const mockDoorStatus = {
doorRequiredClosedForProtocol: true,
},
}
const mockFixture = {
fixtureId: 'mockId',
fixtureLocation: 'D1',
loadName: STAGING_AREA_LOAD_NAME,
} as Fixture

const MOCK_MAKE_SNACKBAR = jest.fn()

describe('ProtocolSetup', () => {
Expand Down Expand Up @@ -305,6 +326,12 @@ describe('ProtocolSetup', () => {
<div>mock ConfirmAttachedModal</div>
)
mockUseDoorQuery.mockReturnValue({ data: mockDoorStatus } as any)
mockUseModulesQuery.mockReturnValue({
data: { data: [mockHeaterShaker] },
} as any)
when(mockUseDeckConfigurationQuery).mockReturnValue({
data: [mockFixture],
} as UseQueryResult<DeckConfiguration>)
when(mockUseToaster)
.calledWith()
.mockReturnValue(({
Expand Down
1 change: 0 additions & 1 deletion app/src/pages/Protocols/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ const useMissingProtocolHardwareFromRequiredProtocolHardare = (
isLoading: boolean
} => {
const { data: deckConfig } = useDeckConfigurationQuery()
console.log('🚀 ~ file: index.ts:252 ~ deckConfig:', deckConfig)

const enableDeckConfigurationFeatureFlag = useFeatureFlag(
'enableDeckConfiguration'
Expand Down

0 comments on commit c063297

Please sign in to comment.