Skip to content

Commit

Permalink
Merge pull request #794 from sanger/x1246-section-reg-bioRisk
Browse files Browse the repository at this point in the history
X1246 section reg bio risk
  • Loading branch information
sabrine33 authored Nov 18, 2024
2 parents b9fff11 + 4b6c8f7 commit 641cd82
Show file tree
Hide file tree
Showing 4 changed files with 1,557 additions and 1,532 deletions.
6 changes: 6 additions & 0 deletions cypress/e2e/pages/sectionRegistration.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ describe('Section Registration Page', () => {
'Section External Identifier contains invalid characters. Only letters, numbers, hyphens, and underscores are permitted'
).should('be.visible');
});

it('requires Biological Risk Assessment Numbers ', () => {
cy.findByLabelText('Biological Risk Assessment Numbers').focus().blur();
cy.findByText('Biological Risk Assessment Numbers is a required field').should('be.visible');
});
});

describe('Initialisation', () => {
Expand Down Expand Up @@ -342,6 +347,7 @@ function fillInForm() {
selectOption('Tissue Type', 'Liver');
selectOption('Spatial Location', '3 - Surface central region');
cy.findByLabelText('Replicate Number').clear().type('2');
selectOption('bioRiskCode', 'bioRisk1');
cy.findByLabelText('Section External Identifier').clear().type('S_EXT_ID_1');
cy.findByLabelText('Sectioned Date').clear().type('2024-07-07');
cy.findByLabelText('Section Number').clear().type('5');
Expand Down
10 changes: 7 additions & 3 deletions src/pages/SectionRegistration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type SectionRegistrationFormSection = {
sectionThickness: number;
region?: string;
dateSectioned?: Date;
bioRiskCode: string;
};

type SectionRegistrationFormLabware = {
Expand Down Expand Up @@ -93,7 +94,8 @@ function buildSectionRegisterRequest(values: SectionRegistrationFormValues): Sec
species: sample.species.trim(),
tissueType: sample.tissueType.trim(),
region: sample.region,
dateSectioned: sample.dateSectioned?.toString()
dateSectioned: sample.dateSectioned?.toString(),
bioRiskCode: sample.bioRiskCode
}));
})
};
Expand Down Expand Up @@ -135,7 +137,8 @@ function buildSample(): SectionRegistrationFormSection {
sectionNumber: 0,
sectionThickness: 0,
region: '',
dateSectioned: undefined
dateSectioned: undefined,
bioRiskCode: ''
};
}

Expand Down Expand Up @@ -166,7 +169,8 @@ function buildValidationSchema(registrationInfo: GetRegistrationInfoQuery) {
sectionNumber: validation.sectionNumber,
sectionThickness: validation.sectionThickness,
region: validation.region,
dateSectioned: validation.dateSectioned
dateSectioned: validation.dateSectioned,
bioRiskCode: validation.bioRiskCode
})
)
)
Expand Down
13 changes: 13 additions & 0 deletions src/pages/registration/SectionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,19 @@ export default function SectionForm({
name={`labwares.${currentIndex}.slots.${slotAddress}.${sectionIndex}.replicateNumber`}
/>

<CustomReactSelect
label="Biological Risk Assessment Numbers"
dataTestId="bioRiskCode"
name={`labwares.${currentIndex}.slots.${slotAddress}.${sectionIndex}.bioRiskCode`}
value={values.labwares[currentIndex].slots[slotAddress][sectionIndex].bioRiskCode}
options={registrationInfo.bioRisks.map((bioRisk) => {
return {
label: bioRisk.code,
value: bioRisk.code
};
})}
/>

<Heading level={4}>Section Information</Heading>

<FormikInput
Expand Down
Loading

0 comments on commit 641cd82

Please sign in to comment.