Align pick item header typography

This commit is contained in:
beatz174-bit committed 2025-11-24 10:00:13 +10:00
1 parent 7665d004ce
commit d36ef675d3
2 files changed
+38 -7

No files matched your search

+28
View File
@@ -29,6 +29,34 @@ const baseProduct: Product = {
}; };
describe('PickItemRow', () => { describe('PickItemRow', () => {
it('keeps quantity inline with matching typography to the product name', () => {
render(
<PickItemRow
item={baseItem}
product={baseProduct}
onIncrementQuantity={vi.fn()}
onDecrementQuantity={vi.fn()}
onToggleCarton={vi.fn()}
onStatusChange={vi.fn()}
onDelete={vi.fn()}
/>,
);
const productName = screen.getByText(baseProduct.name);
const quantityLabel = screen.getByText('1 unit');
const titleRow = screen.getByTestId('pick-item-title-row');
const rowStyle = getComputedStyle(titleRow);
expect(rowStyle.display).toBe('flex');
expect(rowStyle.flexDirection).toBe('row');
const productStyle = getComputedStyle(productName);
const quantityStyle = getComputedStyle(quantityLabel);
expect(productStyle.fontSize).toBe(quantityStyle.fontSize);
expect(productStyle.fontWeight).toBe(quantityStyle.fontWeight);
});
it('asks for confirmation before deleting a product from the pick list', async () => { it('asks for confirmation before deleting a product from the pick list', async () => {
const onDelete = vi.fn(); const onDelete = vi.fn();
const user = userEvent.setup(); const user = userEvent.setup();
+10 -7
View File
@@ -100,27 +100,30 @@ export const PickItemRow = ({
onClick={(event) => event.stopPropagation()} onClick={(event) => event.stopPropagation()}
/> />
<Stack spacing={0.5} minWidth={0} flex={1}> <Stack spacing={0.5} minWidth={0} flex={1}>
<Typography <Stack
variant="subtitle1" direction="row"
noWrap spacing={1}
sx={{ display: 'flex', alignItems: 'center', gap: 1 }} alignItems="center"
data-testid="pick-item-title-row"
sx={{ minWidth: 0 }}
> >
<Typography <Typography
component="span" component="span"
variant="subtitle1" variant="subtitle1"
noWrap noWrap
sx={{ minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis' }} sx={{ minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', fontWeight: 600 }}
> >
{product?.name ?? 'Unknown product'} {product?.name ?? 'Unknown product'}
</Typography> </Typography>
<Typography <Typography
component="span" component="span"
variant="subtitle1" variant="subtitle1"
sx={{ fontWeight: 700, whiteSpace: 'nowrap' }} noWrap
sx={{ fontWeight: 600, whiteSpace: 'nowrap' }}
> >
{item.quantity} {packagingLabel} {item.quantity} {packagingLabel}
</Typography> </Typography>
</Typography> </Stack>
{isNarrowScreen && ( {isNarrowScreen && (
<Typography variant="caption" color="text.secondary" noWrap> <Typography variant="caption" color="text.secondary" noWrap>
Tap to adjust quantity and packaging Tap to adjust quantity and packaging