From 21b96dce6c9dc66aeab8df137c1349ea1a319f36 Mon Sep 17 00:00:00 2001 From: koji Date: Fri, 22 Nov 2024 17:06:51 -0500 Subject: [PATCH] fix(protocol-designer): update Heater-shaker to Heater-Shaker update Heater-shaker to Heater-Shaker close RQA-3675 --- .../src/assets/localization/en/protocol_steps.json | 2 +- .../StepForm/StepTools/HeaterShakerTools/index.tsx | 2 +- .../ProtocolSteps/StepForm/__tests__/utils.test.ts | 5 +++++ .../pages/Designer/ProtocolSteps/StepForm/utils.ts | 13 +++++++++++-- .../ProtocolSteps/Timeline/__tests__/utils.test.tsx | 2 +- .../pages/Designer/ProtocolSteps/Timeline/utils.ts | 10 ++++++++-- 6 files changed, 27 insertions(+), 7 deletions(-) diff --git a/protocol-designer/src/assets/localization/en/protocol_steps.json b/protocol-designer/src/assets/localization/en/protocol_steps.json index 50c6f7879f8..2f498904c61 100644 --- a/protocol-designer/src/assets/localization/en/protocol_steps.json +++ b/protocol-designer/src/assets/localization/en/protocol_steps.json @@ -44,7 +44,7 @@ "open": "open" } }, - "heater_shaker_settings": "Heater-shaker settings", + "heater_shaker_settings": "Heater-Shaker Settings", "in": "in", "into": "into", "magnetic_module": { diff --git a/protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/HeaterShakerTools/index.tsx b/protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/HeaterShakerTools/index.tsx index 5d2035620d3..3447de54069 100644 --- a/protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/HeaterShakerTools/index.tsx +++ b/protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/HeaterShakerTools/index.tsx @@ -41,7 +41,7 @@ export function HeaterShakerTools(props: StepFormProps): JSX.Element { gridGap={SPACING.spacing4} paddingX={SPACING.spacing16} > - + {t('protocol_steps:heater_shaker_settings')} { 'Move labware to D3 on top of Magnetic Block' ) }) + + it('should capitalize the first letter of a step name and leave the rest unchanged', () => { + const moduleName = 'Heater-shaker' + expect(capitalizeFirstLetter(moduleName)).toBe('Heater-Shaker') + }) }) describe('getFormErrorsMappedToField', () => { diff --git a/protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/utils.ts b/protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/utils.ts index 3821d0ba49d..db336a0aba1 100644 --- a/protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/utils.ts +++ b/protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/utils.ts @@ -337,8 +337,17 @@ export const getSaveStepSnackbarText = ( } } -export const capitalizeFirstLetter = (stepName: string): string => - `${stepName.charAt(0).toUpperCase()}${stepName.slice(1)}` +export const capitalizeFirstLetter = (stepName: string): string => { + // Note - check is for heater-shaker + if (stepName.includes('-')) { + return stepName + .split('-') + .map(word => word.charAt(0).toUpperCase() + word.slice(1)) + .join('-') + } else { + return `${stepName.charAt(0).toUpperCase()}${stepName.slice(1)}` + } +} type ErrorMappedToField = Record diff --git a/protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/__tests__/utils.test.tsx b/protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/__tests__/utils.test.tsx index 1d6c2149c95..2baccd90d6b 100644 --- a/protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/__tests__/utils.test.tsx +++ b/protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/__tests__/utils.test.tsx @@ -4,7 +4,7 @@ import { capitalizeFirstLetterAfterNumber } from '../utils' describe('capitalizeFirstLetterAfterNumber', () => { it('should capitalize the first letter of a step type', () => { expect(capitalizeFirstLetterAfterNumber('1. heater-shaker')).toBe( - '1. Heater-shaker' + '1. Heater-Shaker' ) expect(capitalizeFirstLetterAfterNumber('22. thermocycler')).toBe( '22. Thermocycler' diff --git a/protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/utils.ts b/protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/utils.ts index 56b78507a12..2d918b7790f 100644 --- a/protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/utils.ts +++ b/protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/utils.ts @@ -5,8 +5,14 @@ import type { StepIdType } from '../../../../form-types' export const capitalizeFirstLetterAfterNumber = (title: string): string => title.replace( - /(^[\d\W]*)([a-zA-Z])/, - (match, prefix, firstLetter) => `${prefix}${firstLetter.toUpperCase()}` + /(^[\d\W]*)([a-zA-Z])|(-[a-zA-Z])/g, + (match, prefix, firstLetter) => { + if (prefix) { + return `${prefix}${firstLetter.toUpperCase()}` + } else { + return `${match.charAt(0)}${match.charAt(1).toUpperCase()}` + } + } ) const VOLUME_SIG_DIGITS_DEFAULT = 2