Add tests for grouped stock list behavior and improve stock view mode UI and API enhancements
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -70,4 +70,59 @@ describe('stock mark-gone behavior', () => {
|
||||
message: 'Flour was marked gone and removed from the list.',
|
||||
});
|
||||
});
|
||||
|
||||
it('stock list grouped markGone removes item from grouped and flat collections', async () => {
|
||||
useStockItemMock.mockResolvedValueOnce({ status: 'used' });
|
||||
const addAlert = vi.fn();
|
||||
const data = stockListPageData({ addAlert, isConnected: false });
|
||||
|
||||
data.groupedEntries = [
|
||||
{
|
||||
id: 10,
|
||||
uuid_b64: 'group-10',
|
||||
name: 'Beans',
|
||||
stock_type: 'measured',
|
||||
location_initial_uuid_b64: null,
|
||||
date: '2026-04-12',
|
||||
expire_date: '2026-04-20',
|
||||
items: [
|
||||
{
|
||||
id: 11,
|
||||
uuid_b64: 'item-11',
|
||||
name: 'Beans',
|
||||
stock_type: 'measured',
|
||||
quantity: 1,
|
||||
location_initial_uuid_b64: null,
|
||||
date: '2026-04-12',
|
||||
expire_date: '2026-04-20',
|
||||
},
|
||||
],
|
||||
},
|
||||
].map((group) => data.indexGroup(group));
|
||||
data.entries = [
|
||||
data.indexEntry({
|
||||
id: 11,
|
||||
uuid_b64: 'item-11',
|
||||
name: 'Beans',
|
||||
stock_type: 'measured',
|
||||
quantity: 1,
|
||||
location_initial_uuid_b64: null,
|
||||
date: '2026-04-12',
|
||||
expire_date: '2026-04-20',
|
||||
}),
|
||||
];
|
||||
data.entriesVersion = 1;
|
||||
data.groupedVersion = 1;
|
||||
data.editForms = { 11: { level: 'plenty', quantity: 1 } };
|
||||
data.editErrors = {};
|
||||
|
||||
await data.markGoneFromGroup(data.groupedEntries[0].items[0], data.groupedEntries[0]);
|
||||
|
||||
expect(data.entries).toEqual([]);
|
||||
expect(data.groupedEntries).toEqual([]);
|
||||
expect(addAlert).toHaveBeenCalledWith({
|
||||
type: 'success',
|
||||
message: 'Beans was marked gone and removed from the group.',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user