diff --git a/cypress/e2e/pages/cytAssist.cy.ts b/cypress/e2e/pages/cytAssist.cy.ts index 67910d1f5..d7e08fe21 100644 --- a/cypress/e2e/pages/cytAssist.cy.ts +++ b/cypress/e2e/pages/cytAssist.cy.ts @@ -2,14 +2,14 @@ import { selectOption, selectSGPNumber, shouldDisplaySelectedValue } from '../sh import { FindFlaggedLabwareQuery, FindFlaggedLabwareQueryVariables, + FindIfOpExistsQuery, + FindIfOpExistsQueryVariables, LabwareState, ReloadSlotCopyQuery, ReloadSlotCopyQueryVariables, SlideCosting, SlotCopyMutation, - SlotCopyMutationVariables, - FindIfOpExistsQuery, - FindIfOpExistsQueryVariables + SlotCopyMutationVariables } from '../../../src/types/sdk'; import { HttpResponse } from 'msw'; import { LabwareTypeName } from '../../../src/types/stan'; @@ -188,7 +188,9 @@ describe('CytAssist Page', () => { }); }); it('should display Invalid format error message', () => { - cy.findByText('Invalid format for this labware type').should('be.visible'); + cy.contains(`Invalid format for ${LabwareTypeName.VISIUM_LP_CYTASSIST_XL}. Example: V42A20-3752023-10-20`).should( + 'be.visible' + ); }); }); context('When external id is entered in correct format', () => { @@ -222,7 +224,9 @@ describe('CytAssist Page', () => { selectLabwareType(LabwareTypeName.VISIUM_LP_CYTASSIST_HD); }); it('should validate the external barcode ', () => { - cy.contains('Invalid format for VISIUM LP CYTASSIST').should('be.visible'); + cy.contains(`Invalid format for ${LabwareTypeName.VISIUM_LP_CYTASSIST_HD}. Example: H1-9D8VN2V`).should( + 'be.visible' + ); }); it('clears out all the mapping ', () => { cy.findByTestId('STAN-3100').within(() => { diff --git a/src/components/slotMapper/MultipleLabwareSlotMapper.tsx b/src/components/slotMapper/MultipleLabwareSlotMapper.tsx index dc3dff3f4..c7db76565 100644 --- a/src/components/slotMapper/MultipleLabwareSlotMapper.tsx +++ b/src/components/slotMapper/MultipleLabwareSlotMapper.tsx @@ -26,7 +26,7 @@ import WhiteButton from '../buttons/WhiteButton'; import SlotMapperTable, { SlotMapperTableProps } from './SlotMapperTable'; import Warning from '../notifications/Warning'; import { useFormikContext } from 'formik'; -import { CytAssistOutputLabwareForm } from '../../pages/CytAssist'; +import { CytAssistOutputLabwareForm, isVisiumLpCytAssistHdLabware } from '../../pages/CytAssist'; import { flaggedLabwareLayout } from '../../lib/factories/labwareFactory'; import { eventBus } from '../../eventBus'; import { SavedDraft } from '../../lib/machines/slotCopy/slotCopyMachine'; @@ -47,17 +47,17 @@ type SelectedSlot = { type SlotPassFail = Map>; // key labware barcode, failedSlots array of failed slots const validatePreBarcode = (preBarcode: string, labwareType: string) => { - if (labwareType === LabwareTypeName.VISIUM_LP_CYTASSIST_HD) { + if (isVisiumLpCytAssistHdLabware(labwareType)) { const isValid = /^[A-Z0-9]{2}-[A-Z0-9]{7}$/.test(preBarcode); return { valid: isValid, - errorMessage: isValid ? undefined : 'Invalid format for VISIUM LP CYTASSIST HD. Example: H1-9D8VN2V' + errorMessage: isValid ? undefined : `Invalid format for ${labwareType}. Example: H1-9D8VN2V` }; } const isValid = /^[A-Z]\d{2}[A-Z]\d{2}-\d{7}-\d{2}-\d{2}$/.test(preBarcode); return { valid: isValid, - errorMessage: isValid ? undefined : 'Invalid format. Example: V42A20-3752023-10-20' + errorMessage: isValid ? undefined : `Invalid format for ${labwareType}. Example: V42A20-3752023-10-20` }; }; diff --git a/src/pages/CytAssist.tsx b/src/pages/CytAssist.tsx index a66471ec8..9daedc3f4 100644 --- a/src/pages/CytAssist.tsx +++ b/src/pages/CytAssist.tsx @@ -73,18 +73,30 @@ const isCytAssistThreePointLabware = (labwareType: string) => { ); }; +export const isVisiumLpCytAssistHdLabware = (labwareType: string) => { + return ( + labwareType === LabwareTypeName.VISIUM_LP_CYTASSIST_HD || + labwareType === LabwareTypeName.VISIUM_LP_CYTASSIST_HD_11 || + labwareType === LabwareTypeName.VISIUM_LP_CYTASSIST_HD_3_6_5 || + labwareType === LabwareTypeName.VISIUM_LP_CYTASSIST_HD_3_11 + ); +}; + const validationSchema = () => { return Yup.object().shape({ labwareType: Yup.string().required('Required field'), preBarcode: Yup.string().when('labwareType', (labwareType, schema) => { - const val = labwareType[0] as unknown as string; - return val === LabwareTypeName.VISIUM_LP_CYTASSIST_HD + const lt = labwareType[0] as unknown as string; + return isVisiumLpCytAssistHdLabware(lt) ? Yup.string() .required('Required field') - .matches(/[A-Z0-9]{2}-[A-Z0-9]{7}/, 'Invalid format for a labware type of VISIUM_LP_CYTASSIST_HD') + .matches(/[A-Z0-9]{2}-[A-Z0-9]{7}/, `Invalid format for ${labwareType}. Example: H1-9D8VN2V`) : Yup.string() .required('Required field') - .matches(/[A-Z]\d{2}[A-Z]\d{2}-\d{7}-\d{2}-\d{2}/, 'Invalid format for this labware type'); + .matches( + /[A-Z]\d{2}[A-Z]\d{2}-\d{7}-\d{2}-\d{2}/, + `Invalid format for ${labwareType}. Example: V42A20-3752023-10-20V42A20-3752023-10-20` + ); }), lpNumber: Yup.string().oneOf(LP_NUMBERS).required('Required field'), costing: Yup.string().required('Required field'),