Merge branch 'main' into codex/sort-product-list-alphabetically-ddqol8
This commit is contained in:
4 files changed
+113
-44
No files matched your search
@@ -49,7 +49,41 @@ const defaultProducts: Product[] = [
|
||||
|
||||
vi.mock('../hooks/dataHooks', () => ({
|
||||
usePickItems: () => pickItemsMock(),
|
||||
useProducts: () => productsMock(),
|
||||
useProducts: () => [
|
||||
{
|
||||
id: 'prod-1',
|
||||
name: 'Cola',
|
||||
category: 'Drinks',
|
||||
unit_type: 'unit',
|
||||
bulk_name: 'box',
|
||||
barcode: '111',
|
||||
archived: false,
|
||||
created_at: 0,
|
||||
updated_at: 0,
|
||||
},
|
||||
{
|
||||
id: 'prod-2',
|
||||
name: 'Chips',
|
||||
category: 'Snacks',
|
||||
unit_type: 'unit',
|
||||
bulk_name: 'box',
|
||||
barcode: '222',
|
||||
archived: false,
|
||||
created_at: 0,
|
||||
updated_at: 0,
|
||||
},
|
||||
{
|
||||
id: 'prod-3',
|
||||
name: 'Apple Juice',
|
||||
category: 'Drinks',
|
||||
unit_type: 'unit',
|
||||
bulk_name: 'box',
|
||||
barcode: '333',
|
||||
archived: false,
|
||||
created_at: 0,
|
||||
updated_at: 0,
|
||||
},
|
||||
],
|
||||
usePickList: () => ({ id: 'list-1', area_id: 'area-1', created_at: 0 }),
|
||||
useAreas: () => [{ id: 'area-1', name: 'Front Counter', created_at: 0, updated_at: 0 }],
|
||||
}));
|
||||
@@ -140,34 +174,6 @@ describe('ActivePickListScreen product search', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('deduplicates product options with the same id', async () => {
|
||||
const duplicateProducts = [...defaultProducts, { ...defaultProducts[0] }];
|
||||
productsMock.mockReturnValue(duplicateProducts);
|
||||
|
||||
const user = userEvent.setup();
|
||||
|
||||
render(
|
||||
<MemoryRouter initialEntries={['/pick-lists/1']}>
|
||||
<Routes>
|
||||
<Route path="/pick-lists/:id" element={<ActivePickListScreen />} />
|
||||
</Routes>
|
||||
</MemoryRouter>,
|
||||
);
|
||||
|
||||
const combobox = screen.getByRole('combobox');
|
||||
await user.click(combobox);
|
||||
|
||||
const listbox = await screen.findByRole('listbox');
|
||||
const options = within(listbox).getAllByRole('option');
|
||||
|
||||
expect(options).toHaveLength(3);
|
||||
expect(options.map((option) => option.textContent)).toEqual([
|
||||
'Apple Juice (Drinks)',
|
||||
'Chips (Snacks)',
|
||||
'Cola (Drinks)',
|
||||
]);
|
||||
});
|
||||
|
||||
it('updates an existing pick item when the same packaging is selected', async () => {
|
||||
pickItemsMock.mockReturnValue([
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user