Add inactive item fallback for dashboard change feed lookups
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -16,6 +16,7 @@ vi.mock('../../src/api/client.js', () => ({
|
||||
const {
|
||||
adjustStockEntry,
|
||||
applyItemUpsert,
|
||||
getStockEntry,
|
||||
listGroupedStockEntries,
|
||||
listKitchenChanges,
|
||||
listStockEntries,
|
||||
@@ -125,6 +126,35 @@ describe('api/stock', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('getStockEntry fetches item without allow_inactive by default', async () => {
|
||||
apiRequestMock.mockResolvedValueOnce({ uuid_b64: 'item-1', name: 'Milk' });
|
||||
|
||||
const result = await getStockEntry({ config: { database: 'db' } }, 'item-1');
|
||||
|
||||
expect(result).toEqual({ uuid_b64: 'item-1', name: 'Milk' });
|
||||
expect(apiRequestMock).toHaveBeenCalledWith(
|
||||
{ config: { database: 'db' } },
|
||||
'kitchen/items/item-1',
|
||||
);
|
||||
});
|
||||
|
||||
it('getStockEntry forwards allow_inactive when requested', async () => {
|
||||
apiRequestMock.mockResolvedValueOnce({ uuid_b64: 'item-2', active: false });
|
||||
|
||||
const result = await getStockEntry(
|
||||
{ config: { database: 'db' } },
|
||||
'item-2',
|
||||
{ allowInactive: true },
|
||||
);
|
||||
|
||||
expect(result).toEqual({ uuid_b64: 'item-2', active: false });
|
||||
expect(apiRequestMock).toHaveBeenCalledWith(
|
||||
{ config: { database: 'db' } },
|
||||
'kitchen/items/item-2',
|
||||
{ query: { allow_inactive: 1 } },
|
||||
);
|
||||
});
|
||||
|
||||
it('listKitchenChanges returns normalized changes payload', async () => {
|
||||
apiRequestMock.mockResolvedValueOnce({
|
||||
since: 'cursor-1',
|
||||
|
||||
Reference in New Issue
Block a user