|
| 1 | +import { describe, it, beforeEach, vi } from 'vitest' |
| 2 | +import { when } from 'vitest-when' |
| 3 | +import { screen } from '@testing-library/react' |
| 4 | +import { |
| 5 | + getDeckDefFromRobotType, |
| 6 | + FLEX_ROBOT_TYPE, |
| 7 | + OT2_ROBOT_TYPE, |
| 8 | + ot2StandardDeckV4 as ot2StandardDeckDef, |
| 9 | + ot3StandardDeckV4 as ot3StandardDeckDef, |
| 10 | +} from '@opentrons/shared-data' |
| 11 | + |
| 12 | +import { renderWithProviders } from '../../../../__testing-utils__' |
| 13 | +import { getDeckSetupForActiveItem } from '../../../../top-selectors/labware-locations' |
| 14 | +import { selectors } from '../../../../labware-ingred/selectors' |
| 15 | +import { getRobotType } from '../../../../file-data/selectors' |
| 16 | +import { getDisableModuleRestrictions } from '../../../../feature-flags/selectors' |
| 17 | +// import { DeckSetupDetails } from '../../../../pages/Designer/DeckSetup/DeckSetupDetails' |
| 18 | +import { DeckSetupTools } from '../../../../pages/Designer/DeckSetup/DeckSetupTools' |
| 19 | +import { StartingDeckContainer } from '../StartingDeckContainer' |
| 20 | + |
| 21 | +import type * as OpentronsComponents from '@opentrons/components' |
| 22 | + |
| 23 | +vi.mock('../../../../top-selectors/labware-locations') |
| 24 | +// vi.mock('../../../../pages/Designer/DeckSetup/DeckSetupDetails') |
| 25 | +vi.mock('../../../../pages/Designer/DeckSetup/DeckSetupTools') |
| 26 | +vi.mock('../../../../labware-ingred/selectors') |
| 27 | +vi.mock('../../../../feature-flags/selectors') |
| 28 | +vi.mock('../../../../file-data/selectors') |
| 29 | +vi.mock('../../../../pages/Designer/DeckSetup/utils') |
| 30 | +vi.mock('@opentrons/components', async importOriginal => { |
| 31 | + const actual = await importOriginal<typeof OpentronsComponents>() |
| 32 | + return { |
| 33 | + ...actual, |
| 34 | + RobotCoordinateSpaceWithRef: () => ( |
| 35 | + <div>mock RobotCoordinateSpaceWithRef</div> |
| 36 | + ), |
| 37 | + SlotLabels: () => <div>mock SlotLabels</div>, |
| 38 | + DeckFromLayers: () => <div>mock DeckFromLayers</div>, |
| 39 | + SingleSlotFixture: () => <div>mock StagingAreaFixture</div>, |
| 40 | + } |
| 41 | +}) |
| 42 | +vi.mock('@opentrons/shared-data', async importOriginal => { |
| 43 | + const actual = await importOriginal<typeof getDeckDefFromRobotType>() |
| 44 | + return { |
| 45 | + ...actual, |
| 46 | + getDeckDefFromRobotType: vi.fn(), |
| 47 | + } |
| 48 | +}) |
| 49 | + |
| 50 | +const render = () => { |
| 51 | + return renderWithProviders(<StartingDeckContainer />) |
| 52 | +} |
| 53 | + |
| 54 | +describe('StartingDeckContainer', () => { |
| 55 | + beforeEach(() => { |
| 56 | + // vi.mocked(DeckSetupDetails).mockReturnValue( |
| 57 | + // <div>mock DeckSetupDetails</div> |
| 58 | + // ) |
| 59 | + vi.mocked(DeckSetupTools).mockReturnValue(<div>mock DeckSetupTools</div>) |
| 60 | + vi.mocked(getDisableModuleRestrictions).mockReturnValue(false) |
| 61 | + vi.mocked(getRobotType).mockReturnValue(FLEX_ROBOT_TYPE) |
| 62 | + when(vi.mocked(getDeckDefFromRobotType)) |
| 63 | + .calledWith(FLEX_ROBOT_TYPE) |
| 64 | + .thenReturn(ot3StandardDeckDef as any) |
| 65 | + vi.mocked(getDeckSetupForActiveItem).mockReturnValue({ |
| 66 | + labware: {}, |
| 67 | + modules: {}, |
| 68 | + additionalEquipmentOnDeck: {}, |
| 69 | + pipettes: {}, |
| 70 | + }) |
| 71 | + vi.mocked(selectors.getZoomedInSlotInfo).mockReturnValue({ |
| 72 | + selectedLabwareDefUri: null, |
| 73 | + selectedNestedLabwareDefUri: null, |
| 74 | + selectedFixture: null, |
| 75 | + selectedModuleModel: null, |
| 76 | + selectedSlot: { slot: 'D3', cutout: 'cutoutD3' }, |
| 77 | + }) |
| 78 | + vi.mocked(selectors.getZoomedInSlot).mockReturnValue({ |
| 79 | + slot: 'D3', |
| 80 | + cutout: 'cutoutD3', |
| 81 | + }) |
| 82 | + }) |
| 83 | + |
| 84 | + it('should render mock RobotCoordinateSpaceWithRef when robot type is Flex', () => { |
| 85 | + render() |
| 86 | + screen.getByText('mock RobotCoordinateSpaceWithRef') |
| 87 | + screen.getByText('mock DeckSetupTools') |
| 88 | + }) |
| 89 | + |
| 90 | + it('should render mock RobotCoordinateSpaceWithRef when robot type is OT-2', () => { |
| 91 | + when(vi.mocked(getDeckDefFromRobotType)) |
| 92 | + .calledWith(OT2_ROBOT_TYPE) |
| 93 | + .thenReturn(ot2StandardDeckDef as any) |
| 94 | + render() |
| 95 | + screen.getByText('mock RobotCoordinateSpaceWithRef') |
| 96 | + screen.getByText('mock DeckSetupTools') |
| 97 | + }) |
| 98 | + |
| 99 | + // ToDo (kk:03/19/25) add more tests |
| 100 | +}) |
0 commit comments