Skip to content

Commit

Permalink
Merge branch 'protocol_designer-migrate-webpack-to-vite' of github.co…
Browse files Browse the repository at this point in the history
…m:Opentrons/opentrons into protocol_designer-migrate-webpack-to-vite
  • Loading branch information
b-cooper committed Mar 1, 2024
2 parents 2742632 + 8fb9f62 commit 62ee667
Show file tree
Hide file tree
Showing 62 changed files with 6,445 additions and 486 deletions.
1 change: 1 addition & 0 deletions api-client/src/protocols/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from 'vitest'
import {
parsePipetteEntity,
parseInitialPipetteNamesByMount,
Expand Down
35 changes: 21 additions & 14 deletions app/src/assets/labware/__tests__/findLabware.test.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@
import { describe, it, vi, afterEach, expect } from 'vitest'

import { fixtureTiprack10ul, fixtureTiprack300ul } from '@opentrons/shared-data'

import { getLatestLabwareDef } from '../getLabware'
import { findLabwareDefWithCustom } from '../findLabware'

import type { LabwareDefinition2 } from '@opentrons/shared-data'
import fixture_tiprack_10_ul from '@opentrons/shared-data/labware/fixtures/2/fixture_tiprack_10_ul.json'
import fixture_tiprack_300_ul from '@opentrons/shared-data/labware/fixtures/2/fixture_tiprack_300_ul.json'

jest.mock('../getLabware', () => ({
getLatestLabwareDef: jest.fn(),
}))
vi.mock('../getLabware', async importOriginal => {
const actual = await importOriginal<typeof getLatestLabwareDef>()
return {
...actual,
getLatestLabwareDef: vi.fn(),
}
})

const mockGetLabware = getLatestLabwareDef as jest.MockedFunction<
typeof getLatestLabwareDef
>

const fixtureTipRack10ul = fixture_tiprack_10_ul as LabwareDefinition2
const fixtureTipRack10ul = fixtureTiprack10ul as LabwareDefinition2

const fixtureTipRack10ulCustomBeta = {
...fixture_tiprack_10_ul,
...fixtureTiprack10ul,
namespace: 'custom_beta',
} as LabwareDefinition2

const fixtureTipRack10ulVersion2 = {
...fixture_tiprack_10_ul,
...fixtureTiprack10ul,
version: 2,
} as LabwareDefinition2

const fixtureTipRack300ulOpentrons = {
...fixture_tiprack_300_ul,
...fixtureTiprack300ul,
namespace: 'opentrons',
} as LabwareDefinition2

describe('findLabwareDefWithCustom', () => {
afterEach(() => {
jest.resetAllMocks()
vi.resetAllMocks()
})

it('finds standard labware with namesearch', () => {
Expand Down Expand Up @@ -63,16 +70,16 @@ describe('findLabwareDefWithCustom', () => {
const SPECS = [
{
should: 'find nothing with no specs',
customLabware: [fixture_tiprack_10_ul, fixture_tiprack_300_ul],
customLabware: [fixtureTiprack10ul, fixtureTiprack300ul],
expect: null,
namespace: null,
loadName: null,
version: null,
},
{
should: 'find the first item with only namespace',
customLabware: [fixture_tiprack_10_ul, fixture_tiprack_300_ul],
expect: fixture_tiprack_10_ul,
customLabware: [fixtureTiprack10ul, fixtureTiprack300ul],
expect: fixtureTiprack10ul,
namespace: 'fixture',
loadName: null,
version: null,
Expand All @@ -92,7 +99,7 @@ describe('findLabwareDefWithCustom', () => {
{
should: 'find the right item with loadName and namespace',
customLabware: [
fixture_tiprack_10_ul,
fixtureTiprack10ul,
fixtureTipRack10ulCustomBeta,
fixtureTipRack10ulVersion2,
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react'
import { describe, it, expect, vi } from 'vitest'
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { when } from 'vitest-when'
import { renderHook, waitFor } from '@testing-library/react'
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fixture_tiprack_10_ul from '@opentrons/shared-data/labware/fixtures/2/fixture_tiprack_10_ul.json'
import { describe, it, expect } from 'vitest'
import { fixture_tiprack_10_ul } from '@opentrons/shared-data'
import { getFinalLabwareLocation } from '../getFinalLabwareLocation'
import type { LabwareDefinition2 } from '@opentrons/shared-data'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ import { renderWithProviders } from '../../../__testing-utils__'
import { i18n } from '../../../i18n'
import { DeckConfigurationDiscardChangesModal } from '../DeckConfigurationDiscardChangesModal'

import type * as ReactRouterDom from 'react-router-dom'

const mockFunc = vi.fn()
const mockGoBack = vi.fn()
const mockPush = vi.fn()

vi.mock('react-router-dom', () => {
const reactRouterDom = vi.requireActual('react-router-dom')
vi.mock('react-router-dom', async importOriginal => {
const reactRouterDom = await importOriginal<typeof ReactRouterDom>()
return {
...reactRouterDom,
useHistory: () => ({ goBack: mockGoBack } as any),
useHistory: () => ({ push: mockPush } as any),
}
})

Expand Down
Loading

0 comments on commit 62ee667

Please sign in to comment.