-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add data display part to parameters tab
- Loading branch information
Showing
5 changed files
with
273 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunRuntimeParameters.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
import * as React from 'react' | ||
import { describe, it, vi, beforeEach, afterEach, expect } from 'vitest' | ||
import { screen } from '@testing-library/react' | ||
import { when } from 'vitest-when' | ||
|
||
import { renderWithProviders } from '../../../../__testing-utils__' | ||
import { i18n } from '../../../../i18n' | ||
import { NoParameter } from '../../../ProtocolDetails/ProtocolParameters/NoParameter' | ||
import { useMostRecentCompletedAnalysis } from '../../../LabwarePositionCheck/useMostRecentCompletedAnalysis' | ||
|
||
import { ProtocolRunRuntimeParameters } from '../ProtocolRunRunTimeParameters' | ||
|
||
import type { | ||
CompletedProtocolAnalysis, | ||
RunTimeParameter, | ||
} from '@opentrons/shared-data' | ||
|
||
vi.mock('../../../ProtocolDetails/ProtocolParameters/NoParameter') | ||
|
||
const RUN_ID = 'mockId' | ||
|
||
const mockRunTimeParameterData: RunTimeParameter[] = [ | ||
{ | ||
displayName: 'Dry Run', | ||
variableName: 'DRYRUN', | ||
description: 'Is this a dry or wet run? Wet is true, dry is false', | ||
type: 'boolean', | ||
default: false, | ||
}, | ||
{ | ||
displayName: 'Columns of Samples', | ||
variableName: 'COLUMNS', | ||
description: 'How many columns do you want?', | ||
type: 'int', | ||
min: 1, | ||
max: 14, | ||
default: 4, | ||
}, | ||
{ | ||
displayName: 'EtoH Volume', | ||
variableName: 'ETOH_VOLUME', | ||
description: '70% ethanol volume', | ||
type: 'float', | ||
suffix: 'mL', | ||
min: 1.5, | ||
max: 10.0, | ||
default: 6.5, | ||
}, | ||
{ | ||
displayName: 'Default Module Offsets', | ||
variableName: 'DEFAULT_OFFSETS', | ||
description: 'default module offsets for temp, H-S, and none', | ||
type: 'str', | ||
choices: [ | ||
{ | ||
displayName: 'No offsets', | ||
value: 'none', | ||
}, | ||
{ | ||
displayName: 'temp offset', | ||
value: '1', | ||
}, | ||
{ | ||
displayName: 'heater-shaker offset', | ||
value: '2', | ||
}, | ||
], | ||
default: 'none', | ||
}, | ||
] | ||
|
||
const render = ( | ||
props: React.ComponentProps<typeof ProtocolRunRuntimeParameters> | ||
) => { | ||
return renderWithProviders(<ProtocolRunRuntimeParameters {...props} />, { | ||
i18nInstance: i18n, | ||
}) | ||
} | ||
|
||
describe(() => { | ||
let props: React.ComponentProps<typeof ProtocolRunRuntimeParameters> | ||
beforeEach(() => { | ||
props = { | ||
runId: RUN_ID, | ||
} | ||
vi.mocked(NoParameter).mockReturnValue(<div>mock NoParameter</div>) | ||
when(vi.mocked(useMostRecentCompletedAnalysis)) | ||
.calledWith(RUN_ID) | ||
.thenReturn({ | ||
runTimeParameters: mockRunTimeParameterData, | ||
} as CompletedProtocolAnalysis) | ||
}) | ||
|
||
afterEach(() => { | ||
vi.clearAllMocks() | ||
}) | ||
|
||
it('should render title, and banner when RunTimeParameters are note empty', () => { | ||
render(props) | ||
screen.getByText('Parameters') | ||
screen.getByText('Default values') | ||
screen.getByText('Values are view-only') | ||
screen.getByText('Cancel the run and restart setup to edit') | ||
screen.getByText('Name') | ||
screen.getByText('Value') | ||
}) | ||
|
||
it('should render RunTimeParameters when RunTimeParameters are note empty', () => { | ||
render(props) | ||
screen.getByText('Dry Run') | ||
screen.getByText('Off') | ||
screen.getByText('Columns of Samples') | ||
screen.getByText('4') | ||
screen.getByText('EtoH Volume') | ||
screen.getByText('6.5 mL') | ||
screen.getByText('Default Module Offsets') | ||
screen.getByText('No offsets') | ||
}) | ||
|
||
it('should render mock NoParameter component when RunTimeParameters are empty', () => { | ||
when(vi.mocked(useMostRecentCompletedAnalysis)) | ||
.calledWith(RUN_ID) | ||
.thenReturn({ | ||
runTimeParameters: [] as RunTimeParameter[], | ||
} as CompletedProtocolAnalysis) | ||
render(props) | ||
screen.getByText('Parameters') | ||
expect(screen.queryByText('Default values')).not.toBeInTheDocument() | ||
screen.getByText('mock NoParameter') | ||
}) | ||
|
||
// ToDo Additional test will be implemented when chip component is added | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters