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:
@@ -15,6 +15,8 @@ vi.mock('../../src/api/client.js', () => ({
|
||||
|
||||
const {
|
||||
applyItemUpsert,
|
||||
listGroupedStockEntries,
|
||||
listStockEntries,
|
||||
lookupItemByIdentifier,
|
||||
lookupItemDetails,
|
||||
listKitchenChanges,
|
||||
@@ -28,6 +30,51 @@ describe('api/stock', () => {
|
||||
apiRequestMock.mockReset();
|
||||
});
|
||||
|
||||
it('listStockEntries forwards optional query filters', async () => {
|
||||
apiRequestMock.mockResolvedValueOnce([]);
|
||||
|
||||
await listStockEntries(
|
||||
{ config: { database: 'db' } },
|
||||
{ searchName: 'Milk', limit: 20, offset: 40, cursor: 'cursor-1' },
|
||||
);
|
||||
|
||||
expect(apiRequestMock).toHaveBeenCalledWith(
|
||||
{ config: { database: 'db' } },
|
||||
'kitchen/items',
|
||||
{
|
||||
query: {
|
||||
search_name: 'Milk',
|
||||
limit: 20,
|
||||
offset: 40,
|
||||
cursor: 'cursor-1',
|
||||
},
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it('listGroupedStockEntries defaults to expanded=1 and forwards options', async () => {
|
||||
apiRequestMock.mockResolvedValueOnce([]);
|
||||
|
||||
await listGroupedStockEntries(
|
||||
{ config: { database: 'db' } },
|
||||
{ expanded: 0, searchName: 'Rice', limit: 10, offset: 0, cursor: 'cursor-2' },
|
||||
);
|
||||
|
||||
expect(apiRequestMock).toHaveBeenCalledWith(
|
||||
{ config: { database: 'db' } },
|
||||
'kitchen/items/grouped',
|
||||
{
|
||||
query: {
|
||||
expanded: 0,
|
||||
search_name: 'Rice',
|
||||
limit: 10,
|
||||
offset: 0,
|
||||
cursor: 'cursor-2',
|
||||
},
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it('listKitchenChanges returns normalized changes payload', async () => {
|
||||
apiRequestMock.mockResolvedValueOnce({
|
||||
since: 'cursor-1',
|
||||
|
||||
Reference in New Issue
Block a user