Skip to content

Commit

Permalink
Merge pull request #765 from sanger/x1238-decoding-consumables-lot-nu…
Browse files Browse the repository at this point in the history
…mber

add a decoding consumables lot number to the Xenium Analyser operation
  • Loading branch information
khelwood authored Sep 18, 2024
2 parents 4316580 + 27cc770 commit a809d7b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
35 changes: 29 additions & 6 deletions src/pages/XeniumAnalyser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type LabwareSamples = {
type AnalyserLabwareForm = {
labware: LabwareFlaggedFieldsFragment;
workNumber: string;
decodingConsumablesLot?: string;
position?: CassettePosition;
samples: Array<SampleRoi>;
analyserScanData?: AnalyserScanDataFieldsFragment;
Expand Down Expand Up @@ -178,7 +179,10 @@ const XeniumAnalyser = () => {
.of(
Yup.object().shape({
workNumber: Yup.string().required().label('SGP Number'),
position: Yup.string().required().label('Cassette Position'),
position: Yup.string().required(),
decodingConsumablesLot: Yup.string()
.optional()
.matches(/^\d{6}$/, 'Consumables lot number should be a 6-digit number'),
samples: Yup.array()
.of(
Yup.object().shape({
Expand Down Expand Up @@ -237,6 +241,7 @@ const XeniumAnalyser = () => {
labware,
workNumber: values.workNumberAll,
position: undefined,
decodingConsumablesLot: undefined,
samples: [],
analyserScanData: res.analyserScanData
});
Expand All @@ -254,6 +259,7 @@ const XeniumAnalyser = () => {
labware,
workNumber: values.workNumberAll,
position: undefined,
decodingConsumablesLot: undefined,
samples: []
});
return { ...prev };
Expand Down Expand Up @@ -309,6 +315,7 @@ const XeniumAnalyser = () => {
return {
barcode: lw.labware.barcode,
workNumber: lw.workNumber,
decodingConsumablesLot: lw.decodingConsumablesLot,
position: lw.position?.toLowerCase() === 'left' ? CassettePosition.Left : CassettePosition.Right,
samples: labwareSample
? labwareSample.samples.map((sample) => {
Expand Down Expand Up @@ -434,11 +441,17 @@ const XeniumAnalyser = () => {
label={'SGP Number'}
name={'workNumberAll'}
dataTestId={'workNumberAll'}
onWorkNumberChange={(workNumber) => {
setFieldValue('workNumberAll', workNumber);
values.labware.forEach((lw, index) =>
setFieldValue(`labware.${index}.workNumber`, workNumber)
);
onWorkNumberChange={async (workNumber) => {
await setValues((prev) => {
return {
...prev,
workNumberAll: workNumber,
labware: prev.labware.map((lw) => ({
...lw,
workNumber
}))
};
});
}}
requiredField={false}
/>
Expand All @@ -449,6 +462,7 @@ const XeniumAnalyser = () => {
<tr>
<TableHeader>Barcode</TableHeader>
<TableHeader>SGP Number</TableHeader>
<TableHeader>Decoding consumables lot number</TableHeader>
<TableHeader>Cassette Position</TableHeader>
<TableHeader>Samples</TableHeader>
</tr>
Expand All @@ -469,6 +483,15 @@ const XeniumAnalyser = () => {
/>
<FormikErrorMessage name={`labware.${lwIndex}.workNumber`} />
</TableCell>
<TableCell className={'w-20'}>
<div className={'flex flex-col'}>
<FormikInput
label={''}
name={`labware.${lwIndex}.decodingConsumablesLot`}
data-testid={`labware.${lwIndex}.decodingConsumablesLot`}
/>
</div>
</TableCell>
<TableCell>
<CustomReactSelect
options={objectKeys(CassettePosition).map((val) => {
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/pages/lab/xeniumAnalyser.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ describe('Xenium analyser', () => {
});
});
});
describe('Decoding Consumables Lot Number', () => {
it('validates the number if specified', () => {
waitFor(async () => {
await userEvent.type(screen.getByTestId('labware.0.decodingConsumablesLot'), '12234567');
await userEvent.tab();
expect(screen.getByText('Consumables lot number should be a 6-digit number')).toBeVisible();
});
});
});
describe('Save button enabling', () => {
it('should enable Save button when all fields are filled in ', () => {
waitFor(async () => {
Expand Down

0 comments on commit a809d7b

Please sign in to comment.