Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting section thickness inputs only for sectioned slots #872

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions cypress/e2e/pages/sectioningPlanning.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ describe('Sectioning Planning', () => {
cy.findByRole('button', { name: /Next/i }).should('be.disabled');
});

it('section thickness inputs initially are empty and disabled', () => {
cy.findAllByTestId('section-thickness').each((input) => {
cy.wrap(input).should('have.value', '');
cy.wrap(input).should('be.disabled');
});
});

context('when I try and leave the page', () => {
it('shows a confirm box', () => {
cy.on('window:confirm', (str) => {
Expand All @@ -126,7 +133,6 @@ describe('Sectioning Planning', () => {
cy.findByText('A1').click();
cy.findByText('Done').click();
});
cy.findByTestId('section-thickness-A1').type('5');
});

after(() => {
Expand All @@ -136,6 +142,11 @@ describe('Sectioning Planning', () => {
it('enables the Create Labware button', () => {
cy.findByText('Create Labware').should('not.be.disabled');
});

it('enables and set section thickness input to the predefined value', () => {
cy.findAllByTestId('section-thickness').eq(0).should('have.value', '0.5');
cy.findAllByTestId('section-thickness').eq(0).should('be.enabled');
});
});
});

Expand Down Expand Up @@ -266,7 +277,7 @@ function createLabware() {
cy.findByText('A1').click();
cy.findByText('Done').click();
});
cy.findByTestId('section-thickness-A1').clear().type('5');
cy.findByTestId('section-thickness').eq(0).clear().type('5');
cy.findByText('Create Labware').click();
}

Expand Down
68 changes: 35 additions & 33 deletions src/components/planning/LabwarePlan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import ScanInput from '../scanInput/ScanInput';
import FormikSelect from '../forms/Select';
import { objectKeys, Position } from '../../lib/helpers';
import { FormikErrorMessage } from '../forms';
import Table, { TableBody, TableHead, TableHeader } from '../Table';

type LabwarePlanProps = {
/**
Expand Down Expand Up @@ -223,39 +222,42 @@ const LabwarePlan = React.forwardRef<HTMLDivElement, LabwarePlanProps>(
)}

{outputLabware.labwareType.name !== LabwareTypeName.FETAL_WASTE_CONTAINER && (
<Table>
<TableHead>
<tr>
<TableHeader>Slot</TableHeader>
<TableHeader>Section Thickness</TableHeader>
</tr>
</TableHead>
<TableBody>
{outputLabware.slots.map((slot, index) => (
<tr key={index}>
<td className="text-center">{slot.address}</td>
<td>
<FormikInput
className="text-center focus:ring-sdb-100 focus:border-sdb-100 block border-gray-300 rounded-md disabled:opacity-75 disabled:cursor-not-allowed"
label={''}
disabled={current.matches('printing') || current.matches('done')}
name={`sectionThickness[${slot.address}]`}
data-testid={`section-thickness-${slot.address}`}
type="number"
min={0.5}
step={0.5}
onFocus={() => {
setHighlightedSlots(new Set([slot.address]));
}}
onBlur={() => {
setHighlightedSlots(new Set());
}}
/>
</td>
</tr>
<div className="p-4 space-y-2 space-x-2 bg-gray-100">
<div className={'grid grid-cols-2 py-2 text-gray-500 text-center'}>
<div>Section Thickness</div>
</div>
<div className={'flex flex-col space-y-4'}>
{outputLabware.slots.map((slot) => (
<div key={slot.address} className="flex flex-row items-start justify-start gap-x-2">
<span className="font-medium text-gray-800 tracking-wide py-2">{slot.address}</span>
<FormikInput
className="text-center focus:ring-sdb-100 focus:border-sdb-100 block border-gray-300 rounded-md disabled:opacity-75 disabled:cursor-not-allowed disabled:bg-gray-300"
label={''}
disabled={
current.matches('printing') ||
current.matches('done') ||
!current.context.layoutPlan.plannedActions.has(slot.address)
}
name={
current.context.layoutPlan.plannedActions.has(slot.address)
? `sectionThickness[${slot.address}]`
: 'sectionThickness'
}
data-testid={`section-thickness`}
type="number"
min={0.5}
step={0.5}
onFocus={() => {
setHighlightedSlots(new Set([slot.address]));
}}
onBlur={() => {
setHighlightedSlots(new Set());
}}
/>
</div>
))}
</TableBody>
</Table>
</div>
</div>
)}
</div>

Expand Down
Loading