From c8373f5aabd095e268a192a7d470d72daa5bf05f Mon Sep 17 00:00:00 2001 From: ncdiehl11 Date: Wed, 28 Feb 2024 16:54:32 -0500 Subject: [PATCH] testmigrate organisms/devices/protocolrun tests to vitest and update fixture exports --- .../__tests__/SetupLabwareMap.test.tsx | 166 +++++++++++------- .../__tests__/SetupLiquidsList.test.tsx | 8 +- .../__tests__/SetupLiquidsMap.test.tsx | 71 ++++---- .../__tests__/LabwareInfoOverlay.test.tsx | 8 - .../__tests__/ProtocolRunSetup.test.tsx | 63 ++++--- .../SetupPipetteCalibrationItem.test.tsx | 5 +- 6 files changed, 184 insertions(+), 137 deletions(-) diff --git a/app/src/organisms/Devices/ProtocolRun/SetupLabware/__tests__/SetupLabwareMap.test.tsx b/app/src/organisms/Devices/ProtocolRun/SetupLabware/__tests__/SetupLabwareMap.test.tsx index 9ab20ad59e2..8c193d94580 100644 --- a/app/src/organisms/Devices/ProtocolRun/SetupLabware/__tests__/SetupLabwareMap.test.tsx +++ b/app/src/organisms/Devices/ProtocolRun/SetupLabware/__tests__/SetupLabwareMap.test.tsx @@ -4,17 +4,11 @@ import { StaticRouter } from 'react-router-dom' import { describe, it, beforeEach, vi, afterEach, expect } from 'vitest' import { screen } from '@testing-library/react' -import { LabwareRender, Module } from '@opentrons/components' -import { - OT2_ROBOT_TYPE, - getModuleDef2, - fixtureTiprack300ul, -} from '@opentrons/shared-data' +import { BaseDeck } from '@opentrons/components' +import { OT2_ROBOT_TYPE, getModuleDef2 } from '@opentrons/shared-data' +import { fixtureTiprack300ul as fixture_tiprack_300_ul } from '@opentrons/shared-data' -import { - partialComponentPropsMatcher, - renderWithProviders, -} from '../../../../../__testing-utils__' +import { renderWithProviders } from '../../../../../__testing-utils__' import { i18n } from '../../../../../i18n' import { getAttachedProtocolModuleMatches } from '../../../../ProtocolSetupModulesAndDeck/utils' import { LabwareInfoOverlay } from '../../LabwareInfoOverlay' @@ -27,12 +21,19 @@ import type { ModuleModel, ModuleType, } from '@opentrons/shared-data' +import type Components from '@opentrons/components' +import type SharedData from '@opentrons/shared-data' +import { fixtureTiprack300ul } from '@opentrons/shared-data' -vi.mock('@opentrons/components/src/hardware-sim/Labware/LabwareRender') -vi.mock('@opentrons/components/src/hardware-sim/Module') - +vi.mock('@opentrons/components', async importOriginal => { + const actualComponents = await importOriginal() + return { + ...actualComponents, + BaseDeck: vi.fn(), + } +}) vi.mock('@opentrons/shared-data', async importOriginal => { - const actualSharedData = await importOriginal() + const actualSharedData = await importOriginal() return { ...actualSharedData, getModuleDef2: vi.fn(), @@ -92,32 +93,33 @@ const render = (props: React.ComponentProps) => { describe('SetupLabwareMap', () => { beforeEach(() => { - when(vi.mocked(getAttachedProtocolModuleMatches)).thenReturn([]) - when(vi.mocked(getLabwareRenderInfo)).thenReturn({}) - when(vi.mocked(LabwareRender)) - .thenReturn(
) // this (default) empty div will be returned when LabwareRender isn't called with expected labware definition - .calledWith( - partialComponentPropsMatcher({ - definition: fixtureTiprack300ul, - }) - ) - .thenReturn( -
- mock labware render of {fixtureTiprack300ul.metadata.displayName} -
- ) + vi.mocked(getAttachedProtocolModuleMatches).mockReturnValue([]) + vi.mocked(getLabwareRenderInfo).mockReturnValue({}) + vi.mocked(BaseDeck).mockReturnValue(
mock baseDeck
) + // when(vi.mocked(LabwareRender)) + // .called.thenReturn(
) // this (default) empty div will be returned when LabwareRender isn't called with expected labware definition + // .calledWith( + // partialComponentPropsMatcher({ + // definition: fixture_tiprack_300_ul, + // }) + // ) + // .thenReturn( + //
+ // mock labware render of {fixture_tiprack_300_ul.metadata.displayName} + //
+ // ) - when(vi.mocked(LabwareInfoOverlay)) - .thenReturn(
) // this (default) empty div will be returned when LabwareInfoOverlay isn't called with expected props - .calledWith( - partialComponentPropsMatcher({ definition: fixtureTiprack300ul }) - ) - .thenReturn( -
- mock labware info overlay of{' '} - {fixtureTiprack300ul.metadata.displayName} -
- ) + // when(vi.mocked(LabwareInfoOverlay)) + // .thenReturn(
) // this (default) empty div will be returned when LabwareInfoOverlay isn't called with expected props + // .calledWith( + // partialComponentPropsMatcher({ definition: fixture_tiprack_300_ul }) + // ) + // .thenReturn( + //
+ // mock labware info overlay of{' '} + // {fixture_tiprack_300_ul.metadata.displayName} + //
+ // ) }) afterEach(() => { @@ -125,12 +127,22 @@ describe('SetupLabwareMap', () => { }) it('should render a deck WITHOUT labware and WITHOUT modules', () => { - expect(vi.mocked(Module)).not.toHaveBeenCalled() - expect(vi.mocked(LabwareRender)).not.toHaveBeenCalled() + render({ + runId: RUN_ID, + protocolAnalysis: ({ + commands: [], + labware: [], + robotType: OT2_ROBOT_TYPE, + } as unknown) as CompletedProtocolAnalysis, + }) expect(vi.mocked(LabwareInfoOverlay)).not.toHaveBeenCalled() + expect(vi.mocked(BaseDeck)).toHaveBeenCalledWith( + expect.objectContaining({ labwareOnDeck: [], modulesOnDeck: [] }), + expect.anything() + ) }) it('should render a deck WITH labware and WITHOUT modules', () => { - when(vi.mocked(getLabwareRenderInfo)).thenReturn({ + vi.mocked(getLabwareRenderInfo).mockReturnValue({ '300_ul_tiprack_id': { labwareDef: fixtureTiprack300ul as LabwareDefinition2, displayName: 'fresh tips', @@ -140,7 +152,6 @@ describe('SetupLabwareMap', () => { slotName: '1', }, }) - render({ runId: RUN_ID, protocolAnalysis: ({ @@ -150,15 +161,23 @@ describe('SetupLabwareMap', () => { } as unknown) as CompletedProtocolAnalysis, }) - expect(vi.mocked(Module)).not.toHaveBeenCalled() - expect(vi.mocked(LabwareRender)).toHaveBeenCalled() - expect(vi.mocked(LabwareInfoOverlay)).toHaveBeenCalled() - screen.getByText('mock labware render of 300ul Tiprack FIXTURE') - screen.getByText('mock labware info overlay of 300ul Tiprack FIXTURE') + expect(vi.mocked(BaseDeck)).toHaveBeenCalledWith( + expect.objectContaining( + { + labwareOnDeck: [ + expect.objectContaining( + { definition: fixtureTiprack300ul }, + expect.anything() + ), + ], + }, + expect.anything() + ) + ) }) it('should render a deck WITH labware and WITH modules', () => { - when(vi.mocked(getLabwareRenderInfo)).thenReturn({ + vi.mocked(getLabwareRenderInfo).mockReturnValue({ [MOCK_300_UL_TIPRACK_ID]: { labwareDef: fixtureTiprack300ul as LabwareDefinition2, displayName: 'fresh tips', @@ -169,7 +188,7 @@ describe('SetupLabwareMap', () => { }, }) - when(vi.mocked(getAttachedProtocolModuleMatches)).thenReturn([ + vi.mocked(getAttachedProtocolModuleMatches).mockReturnValue([ { moduleId: mockMagneticModule.moduleId, x: MOCK_MAGNETIC_MODULE_COORDS[0], @@ -203,21 +222,21 @@ describe('SetupLabwareMap', () => { .calledWith(mockTCModule.model) .thenReturn(mockTCModule as any) - when(vi.mocked(Module)) - .calledWith( - partialComponentPropsMatcher({ - def: mockMagneticModule, - }) - ) - .thenReturn(
mock module viz {mockMagneticModule.type}
) + // when(vi.mocked(Module)) + // .calledWith( + // partialComponentPropsMatcher({ + // def: mockMagneticModule, + // }) + // ) + // .thenReturn(
mock module viz {mockMagneticModule.type}
) - when(vi.mocked(Module)) - .calledWith( - partialComponentPropsMatcher({ - def: mockTCModule, - }) - ) - .thenReturn(
mock module viz {mockTCModule.type}
) + // when(vi.mocked(Module)) + // .calledWith( + // partialComponentPropsMatcher({ + // def: mockTCModule, + // }) + // ) + // .thenReturn(
mock module viz {mockTCModule.type}
) render({ runId: RUN_ID, @@ -228,6 +247,25 @@ describe('SetupLabwareMap', () => { } as unknown) as CompletedProtocolAnalysis, }) + expect(vi.mocked(Module)).toHaveBeenNthCalledWith( + 1, + expect.objectContaining({ + def: mockMagneticModule, + }) + ) + expect(vi.mocked(Module)).toHaveBeenNthCalledWith( + 2, + expect.objectContaining({ + def: mockTCModule, + }) + ) + expect(vi.mocked(LabwareRender)).toHaveBeenCalledWith( + expect.objectContaining({ definition: fixture_tiprack_300_ul }) + ) + expect(vi.mocked(LabwareInfoOverlay)).toHaveBeenCalledWith( + expect.objectContaining({ definition: fixture_tiprack_300_ul }) + ) + screen.getByText('mock module viz magneticModuleType') screen.getByText('mock module viz thermocyclerModuleType') screen.getByText('mock labware render of 300ul Tiprack FIXTURE') diff --git a/app/src/organisms/Devices/ProtocolRun/SetupLiquids/__tests__/SetupLiquidsList.test.tsx b/app/src/organisms/Devices/ProtocolRun/SetupLiquids/__tests__/SetupLiquidsList.test.tsx index b046defdef3..9ac15a98a35 100644 --- a/app/src/organisms/Devices/ProtocolRun/SetupLiquids/__tests__/SetupLiquidsList.test.tsx +++ b/app/src/organisms/Devices/ProtocolRun/SetupLiquids/__tests__/SetupLiquidsList.test.tsx @@ -10,7 +10,6 @@ import { import { nestedTextMatcher, - partialComponentPropsMatcher, renderWithProviders, } from '../../../../../__testing-utils__' import { i18n } from '../../../../../i18n' @@ -89,9 +88,10 @@ describe('SetupLiquidsList', () => { ) when(vi.mocked(LiquidsLabwareDetailsModal)) .calledWith( - partialComponentPropsMatcher({ labwareId: '123', liquidId: '0' }) + expect.objectContaining({ labwareId: '123', liquidId: '0' }), + expect.anything() ) - .thenReturn(
Mock liquids labwaqre details modal
) + .thenReturn(
Mock liquids labware details modal
) }) it('renders the total volume of the liquid, sample display name, and description', () => { @@ -129,6 +129,6 @@ describe('SetupLiquidsList', () => { name: ANALYTICS_OPEN_LIQUID_LABWARE_DETAIL_MODAL, properties: {}, }) - screen.getByText('Mock liquids labwaqre details modal') + screen.getByText('Mock liquids labware details modal') }) }) diff --git a/app/src/organisms/Devices/ProtocolRun/SetupLiquids/__tests__/SetupLiquidsMap.test.tsx b/app/src/organisms/Devices/ProtocolRun/SetupLiquids/__tests__/SetupLiquidsMap.test.tsx index ec10eeedc48..9a465f18fd5 100644 --- a/app/src/organisms/Devices/ProtocolRun/SetupLiquids/__tests__/SetupLiquidsMap.test.tsx +++ b/app/src/organisms/Devices/ProtocolRun/SetupLiquids/__tests__/SetupLiquidsMap.test.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import { when } from 'vitest-when' import { screen } from '@testing-library/react' -import { describe, it, beforeEach, vi, afterEach } from 'vitest' +import { describe, it, beforeEach, vi, afterEach, expect } from 'vitest' import { BaseDeck, LabwareRender } from '@opentrons/components' import { @@ -21,10 +21,7 @@ import { simpleAnalysisFileFixture, } from '@opentrons/api-client' -import { - partialComponentPropsMatcher, - renderWithProviders, -} from '../../../../../__testing-utils__' +import { renderWithProviders } from '../../../../../__testing-utils__' import { i18n } from '../../../../../i18n' import { useAttachedModules } from '../../../hooks' import { LabwareInfoOverlay } from '../../LabwareInfoOverlay' @@ -42,9 +39,11 @@ import type { ModuleType, LabwareDefinition2, } from '@opentrons/shared-data' +import type * as Components from '@opentrons/components' +import { LabwareInfo } from '@opentrons/components/src/hardware-sim/ProtocolDeck/LabwareInfo' -vi.mock('@opentrons/components', () => { - const actualComponents = vi.requireActual('@opentrons/components') +vi.mock('@opentrons/components', async importOriginal => { + const actualComponents = await importOriginal() return { ...actualComponents, LabwareRender: vi.fn(() =>
mock LabwareRender
), @@ -108,26 +107,28 @@ describe('SetupLiquidsMap', () => { protocolAnalysis: mockProtocolAnalysis, } when(vi.mocked(LabwareRender)) - .thenReturn(
) // this (default) empty div will be returned when LabwareRender isn't called with expected labware definition .calledWith( - partialComponentPropsMatcher({ + expect.objectContaining({ definition: fixtureTiprack300ul, wellFill: undefined, - }) + }), + expect.anything() ) .thenReturn(
mock labware render of {fixtureTiprack300ul.metadata.displayName}
) + when(vi.mocked(LabwareRender)) .calledWith( - partialComponentPropsMatcher({ + expect.objectContaining({ wellFill: { C1: '#ff4888', C2: '#ff4888' }, - }) + }), + expect.anything() ) .thenReturn(
mock labware render with well fill
) when(vi.mocked(useAttachedModules)).calledWith().thenReturn([]) - when(vi.mocked(getAttachedProtocolModuleMatches)).thenReturn([]) + vi.mocked(getAttachedProtocolModuleMatches).mockReturnValue([]) when(vi.mocked(getLabwareRenderInfo)) .calledWith(mockProtocolAnalysis, ot2StandardDeckDef as any) .thenReturn({}) @@ -144,9 +145,9 @@ describe('SetupLiquidsMap', () => { .calledWith(mockProtocolAnalysis.commands as any) .thenReturn({}) when(vi.mocked(LabwareInfoOverlay)) - .thenReturn(
) // this (default) empty div will be returned when LabwareInfoOverlay isn't called with expected props .calledWith( - partialComponentPropsMatcher({ definition: fixtureTiprack300ul }) + expect.objectContaining({ definition: fixtureTiprack300ul }), + expect.anything() ) .thenReturn(
@@ -154,6 +155,12 @@ describe('SetupLiquidsMap', () => { {fixtureTiprack300ul.metadata.displayName}
) + when(vi.mocked(LabwareInfoOverlay)) + .calledWith( + expect.not.objectContaining({ definition: fixtureTiprack300ul }), + expect.anything() + ) + .thenReturn(
) }) afterEach(() => { @@ -173,23 +180,23 @@ describe('SetupLiquidsMap', () => { it('should render base deck - robot type is OT-2', () => { when(vi.mocked(getDeckDefFromRobotType)) .calledWith(OT2_ROBOT_TYPE) - .mockReturnValue(ot2StandardDeckDef as any) + .thenReturn(ot2StandardDeckDef as any) when(vi.mocked(parseLabwareInfoByLiquidId)) .calledWith(mockProtocolAnalysis.commands as any) - .mockReturnValue({}) + .thenReturn({}) vi.mocked(useAttachedModules).mockReturnValue( mockFetchModulesSuccessActionPayloadModules ) - when(vi.mocked(getLabwareRenderInfo)).mockReturnValue({}) + vi.mocked(getLabwareRenderInfo).mockReturnValue({}) when(vi.mocked(getProtocolModulesInfo)) .calledWith(mockProtocolAnalysis, ot2StandardDeckDef as any) - .mockReturnValue(mockProtocolModuleInfo) + .thenReturn(mockProtocolModuleInfo) when(vi.mocked(getAttachedProtocolModuleMatches)) .calledWith( mockFetchModulesSuccessActionPayloadModules, mockProtocolModuleInfo ) - .mockReturnValue([ + .thenReturn([ { moduleId: mockMagneticModule.moduleId, x: MOCK_MAGNETIC_MODULE_COORDS[0], @@ -220,12 +227,13 @@ describe('SetupLiquidsMap', () => { when(mockBaseDeck) .calledWith( - partialComponentPropsMatcher({ + expect.objectContaining({ robotType: OT2_ROBOT_TYPE, deckLayerBlocklist: getStandardDeckViewLayerBlockList(OT2_ROBOT_TYPE), - }) + }), + expect.anything() ) - .mockReturnValue(
mock BaseDeck
) + .thenReturn(
mock BaseDeck
) render(props) screen.getByText('mock BaseDeck') }) @@ -244,11 +252,11 @@ describe('SetupLiquidsMap', () => { } when(vi.mocked(getDeckDefFromRobotType)) .calledWith(FLEX_ROBOT_TYPE) - .mockReturnValue(ot3StandardDeckDef as any) + .thenReturn(ot3StandardDeckDef as any) when(vi.mocked(getLabwareRenderInfo)) .calledWith(mockFlexAnalysis, ot3StandardDeckDef as any) - .mockReturnValue({ + .thenReturn({ [MOCK_300_UL_TIPRACK_ID]: { labwareDef: fixtureTiprack300ul as LabwareDefinition2, displayName: 'fresh tips', @@ -261,20 +269,20 @@ describe('SetupLiquidsMap', () => { when(vi.mocked(parseLabwareInfoByLiquidId)) .calledWith(mockFlexAnalysis.commands as any) - .mockReturnValue({}) + .thenReturn({}) vi.mocked(useAttachedModules).mockReturnValue( mockFetchModulesSuccessActionPayloadModules ) when(vi.mocked(getProtocolModulesInfo)) .calledWith(mockFlexAnalysis, ot3StandardDeckDef as any) - .mockReturnValue(mockProtocolModuleInfo) + .thenReturn(mockProtocolModuleInfo) when(vi.mocked(getAttachedProtocolModuleMatches)) .calledWith( mockFetchModulesSuccessActionPayloadModules, mockProtocolModuleInfo ) - .mockReturnValue([ + .thenReturn([ { moduleId: mockMagneticModule.moduleId, x: MOCK_MAGNETIC_MODULE_COORDS[0], @@ -304,7 +312,7 @@ describe('SetupLiquidsMap', () => { ]) when(mockBaseDeck) .calledWith( - partialComponentPropsMatcher({ + expect.objectContaining({ deckLayerBlocklist: getStandardDeckViewLayerBlockList( FLEX_ROBOT_TYPE ), @@ -312,9 +320,10 @@ describe('SetupLiquidsMap', () => { // // ToDo (kk:11/03/2023) Update the following part later labwareOnDeck: expect.anything(), modulesOnDeck: expect.anything(), - }) + }), + expect.anything() ) - .mockReturnValue(
mock BaseDeck
) + .thenReturn(
mock BaseDeck
) render(props) screen.getByText('mock BaseDeck') }) diff --git a/app/src/organisms/Devices/ProtocolRun/__tests__/LabwareInfoOverlay.test.tsx b/app/src/organisms/Devices/ProtocolRun/__tests__/LabwareInfoOverlay.test.tsx index 47d92466df4..c56281c127b 100644 --- a/app/src/organisms/Devices/ProtocolRun/__tests__/LabwareInfoOverlay.test.tsx +++ b/app/src/organisms/Devices/ProtocolRun/__tests__/LabwareInfoOverlay.test.tsx @@ -27,14 +27,6 @@ vi.mock('../../hooks') vi.mock('../utils/getLabwareDefinitionUri') vi.mock('../useLabwareOffsetForLabware') -// jest.mock('@opentrons/shared-data', () => { -// const actualSharedData = jest.requireActual('@opentrons/shared-data') -// return { -// ...actualSharedData, -// getLabwareDisplayName: jest.fn(), -// } -// }) - vi.mock('@opentrons/shared-data', async importOriginal => { const actual = await importOriginal() return { diff --git a/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunSetup.test.tsx b/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunSetup.test.tsx index eafbeccae5e..a862c1c094f 100644 --- a/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunSetup.test.tsx +++ b/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunSetup.test.tsx @@ -12,13 +12,12 @@ import { ProtocolAnalysisOutput, STAGING_AREA_SLOT_WITH_WASTE_CHUTE_RIGHT_ADAPTER_NO_COVER_FIXTURE, } from '@opentrons/shared-data' -import noModulesProtocol from '@opentrons/shared-data/protocol/fixtures/4/simpleV4.json' -import withModulesProtocol from '@opentrons/shared-data/protocol/fixtures/4/testModulesProtocol.json' - import { - partialComponentPropsMatcher, - renderWithProviders, -} from '../../../../__testing-utils__' + simple_v4 as noModulesProtocol, + test_modules_protocol as withModulesProtocol, +} from '@opentrons/shared-data' + +import { renderWithProviders } from '../../../../__testing-utils__' import { i18n } from '../../../../i18n' import { mockConnectedRobot } from '../../../../redux/discovery/__fixtures__' import { @@ -43,6 +42,7 @@ import { SetupLiquids } from '../SetupLiquids' import { SetupModuleAndDeck } from '../SetupModuleAndDeck' import { EmptySetupStep } from '../EmptySetupStep' import { ProtocolRunSetup } from '../ProtocolRunSetup' +import type * as SharedData from '@opentrons/shared-data' vi.mock('@opentrons/api-client') vi.mock('../../hooks') @@ -52,11 +52,17 @@ vi.mock('../SetupModuleAndDeck') vi.mock('../SetupLiquids') vi.mock('../EmptySetupStep') vi.mock('../../../LabwarePositionCheck/useMostRecentCompletedAnalysis') -vi.mock('@opentrons/shared-data/js/helpers/parseProtocolData') -vi.mock('@opentrons/shared-data/js/helpers/getSimplestFlexDeckConfig') vi.mock('../../../../redux/config') vi.mock('../../../../resources/deck_configuration/utils') vi.mock('../../../../resources/deck_configuration/hooks') +vi.mock('@opentrons/shared-data', async importOriginal => { + const actualSharedData = await importOriginal() + return { + ...actualSharedData, + parseProtocolData: vi.fn(), + getSimplestDeckConfigForProtocol: vi.fn(), + } +}) const ROBOT_NAME = 'otie' const RUN_ID = '1' @@ -92,8 +98,8 @@ describe('ProtocolRunSetup', () => { ...noModulesProtocol, ...MOCK_ROTOCOL_LIQUID_KEY, } as unknown) as ProtocolAnalysisOutput) - when(vi.mocked(parseAllRequiredModuleModels)).thenReturn([]) - when(vi.mocked(parseLiquidsInLoadOrder)).thenReturn([]) + vi.mocked(parseAllRequiredModuleModels).mockReturnValue([]) + vi.mocked(parseLiquidsInLoadOrder).mockReturnValue([]) when(vi.mocked(useRobot)) .calledWith(ROBOT_NAME) .thenReturn(mockConnectedRobot) @@ -103,31 +109,36 @@ describe('ProtocolRunSetup', () => { when(vi.mocked(useRunHasStarted)).calledWith(RUN_ID).thenReturn(false) when(vi.mocked(SetupRobotCalibration)) .calledWith( - partialComponentPropsMatcher({ + expect.objectContaining({ robotName: ROBOT_NAME, runId: RUN_ID, - }) + }), + expect.anything() ) .thenReturn(Mock SetupRobotCalibration) when(vi.mocked(SetupLabware)) .calledWith( - partialComponentPropsMatcher({ + expect.objectContaining({ protocolRunHeaderRef: null, robotName: ROBOT_NAME, runId: RUN_ID, - }) + }), + expect.anything() ) .thenReturn(Mock SetupLabware) - when(vi.mocked(SetupModuleAndDeck)).thenReturn(
Mock SetupModules
) - when(vi.mocked(SetupLiquids)).thenReturn(
Mock SetupLiquids
) - when(vi.mocked(EmptySetupStep)).thenReturn(
Mock EmptySetupStep
) - when(vi.mocked(getSimplestDeckConfigForProtocol)).thenReturn([]) - when(vi.mocked(useDeckConfigurationCompatibility)).thenReturn([]) - when(vi.mocked(getRequiredDeckConfig)).thenReturn([]) + vi.mocked(SetupRobotCalibration).mockReturnValue( +
Mock SetupRobotCalibration
+ ) + vi.mocked(SetupModuleAndDeck).mockReturnValue(
Mock SetupModules
) + vi.mocked(SetupLiquids).mockReturnValue(
Mock SetupLiquids
) + vi.mocked(EmptySetupStep).mockReturnValue(
Mock EmptySetupStep
) + vi.mocked(getSimplestDeckConfigForProtocol).mockReturnValue([]) + vi.mocked(useDeckConfigurationCompatibility).mockReturnValue([]) + vi.mocked(getRequiredDeckConfig).mockReturnValue([]) when(vi.mocked(useUnmatchedModulesForProtocol)) .calledWith(ROBOT_NAME, RUN_ID) .thenReturn({ missingModuleIds: [], remainingAttachedModules: [] }) - when(vi.mocked(getIsFixtureMismatch)).thenReturn(false) + vi.mocked(getIsFixtureMismatch).mockReturnValue(false) }) afterEach(() => { vi.resetAllMocks() @@ -225,7 +236,7 @@ describe('ProtocolRunSetup', () => { describe('when modules are in the protocol', () => { beforeEach(() => { - when(vi.mocked(parseAllRequiredModuleModels)).thenReturn([ + vi.mocked(parseAllRequiredModuleModels).mockReturnValue([ 'magneticModuleV1', 'temperatureModuleV1', ]) @@ -303,7 +314,7 @@ describe('ProtocolRunSetup', () => { missingLabwareDisplayName: null, }, ]) - when(vi.mocked(getRequiredDeckConfig)).thenReturn([ + vi.mocked(getRequiredDeckConfig).mockReturnValue([ { cutoutId: 'cutoutA1', cutoutFixtureId: STAGING_AREA_SLOT_WITH_WASTE_CHUTE_RIGHT_ADAPTER_NO_COVER_FIXTURE, @@ -313,7 +324,7 @@ describe('ProtocolRunSetup', () => { ], }, ] as any) - when(vi.mocked(getIsFixtureMismatch)).thenReturn(true) + vi.mocked(getIsFixtureMismatch).mockReturnValue(true) when(vi.mocked(useIsFlex)).calledWith(ROBOT_NAME).thenReturn(true) when(vi.mocked(useModuleCalibrationStatus)) .calledWith(ROBOT_NAME, RUN_ID) @@ -366,7 +377,7 @@ describe('ProtocolRunSetup', () => { }, ], } as any) - when(vi.mocked(parseAllRequiredModuleModels)).thenReturn([ + vi.mocked(parseAllRequiredModuleModels).mockReturnValue([ 'magneticModuleV1', ]) render() @@ -402,7 +413,7 @@ describe('ProtocolRunSetup', () => { }, ], } as any) - when(vi.mocked(parseAllRequiredModuleModels)).thenReturn([ + vi.mocked(parseAllRequiredModuleModels).mockReturnValue([ 'magneticModuleV1', ]) render() diff --git a/app/src/organisms/Devices/ProtocolRun/__tests__/SetupPipetteCalibrationItem.test.tsx b/app/src/organisms/Devices/ProtocolRun/__tests__/SetupPipetteCalibrationItem.test.tsx index 30fed2b3abb..225dfaddcb4 100644 --- a/app/src/organisms/Devices/ProtocolRun/__tests__/SetupPipetteCalibrationItem.test.tsx +++ b/app/src/organisms/Devices/ProtocolRun/__tests__/SetupPipetteCalibrationItem.test.tsx @@ -13,9 +13,6 @@ import { MemoryRouter } from 'react-router-dom' vi.mock('../../hooks') -const mockUseDeckCalibrationData = useDeckCalibrationData as jest.MockedFunction< - typeof useDeckCalibrationData -> const ROBOT_NAME = 'otie' const RUN_ID = '1' @@ -44,7 +41,7 @@ describe('SetupPipetteCalibrationItem', () => { } beforeEach(() => { - when(mockUseDeckCalibrationData).calledWith(ROBOT_NAME).thenReturn({ + when(vi.mocked(useDeckCalibrationData)).calledWith(ROBOT_NAME).thenReturn({ deckCalibrationData: mockDeckCalData, isDeckCalibrated: true, })