diff --git a/tests/features/labels/upsert-submit.test.js b/tests/features/labels/upsert-submit.test.js index 9a6e141..c2a3ca0 100644 --- a/tests/features/labels/upsert-submit.test.js +++ b/tests/features/labels/upsert-submit.test.js @@ -299,10 +299,10 @@ describe('label create upsert-first submit', () => { await data.create(); - expect(data.printIssue).toBe('Printer is unavailable.'); + expect(data.printIssue).toBe('Beans was created, but printing failed: Printer is unavailable.'); expect(addAlert).toHaveBeenCalledWith({ type: 'warning', - message: 'Beans was created, but printing has an issue: Printer is unavailable.', + message: 'Beans was created, but printing failed: Printer is unavailable.', }); expect(localStorageMock.setItem).toHaveBeenCalled(); }); diff --git a/tests/features/stock/mark-gone.test.js b/tests/features/stock/mark-gone.test.js index 3674b9d..25cf90c 100644 --- a/tests/features/stock/mark-gone.test.js +++ b/tests/features/stock/mark-gone.test.js @@ -1,11 +1,11 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; -const useStockItemMock = vi.fn(); +const markStockGoneMock = vi.fn(); const getStockEntryMock = vi.fn(); const listGroupedStockEntriesMock = vi.fn(); vi.mock('../../../src/api/stock.js', () => ({ - useStockItem: (...args) => useStockItemMock(...args), + markStockGone: (...args) => markStockGoneMock(...args), getStockEntry: (...args) => getStockEntryMock(...args), adjustStockEntry: vi.fn(), lookupItemDetails: vi.fn(), @@ -24,7 +24,7 @@ const { stockListPageData } = await import('../../../src/features/stock/stock-li describe('stock mark-gone behavior', () => { beforeEach(() => { - useStockItemMock.mockReset(); + markStockGoneMock.mockReset(); getStockEntryMock.mockReset(); listGroupedStockEntriesMock.mockReset(); globalThis.window = { @@ -39,15 +39,15 @@ describe('stock mark-gone behavior', () => { delete globalThis.window; }); - it('stock detail markGone uses /use and shows info for already gone', async () => { - useStockItemMock.mockResolvedValueOnce({ status: 'already_gone' }); + it('stock detail markGone posts gone event and shows info for already gone', async () => { + markStockGoneMock.mockResolvedValueOnce({ status: 'already_gone' }); const addAlert = vi.fn(); const data = stockDetailPageData({ addAlert }); data.entry = { uuid_b64: 'item-1', name: 'Rice' }; await data.markGone(); - expect(useStockItemMock).toHaveBeenCalledWith({ addAlert }, 'item-1'); + expect(markStockGoneMock).toHaveBeenCalledWith({ addAlert }, 'item-1', 'consumed'); expect(addAlert).toHaveBeenCalledWith({ type: 'info', message: 'Rice was already out of stock.', @@ -55,8 +55,8 @@ describe('stock mark-gone behavior', () => { expect(globalThis.window.__loncApp.navigate).toHaveBeenCalledWith('/stock'); }); - it('stock list markGone removes entry and uses /use path', async () => { - useStockItemMock.mockResolvedValueOnce({ status: 'used' }); + it('stock list markGone removes entry and posts gone event', async () => { + markStockGoneMock.mockResolvedValueOnce({ status: 'ok' }); const addAlert = vi.fn(); const data = stockListPageData({ addAlert, isConnected: false }); data.entries = [{ id: 1, uuid_b64: 'item-1', name: 'Flour' }]; @@ -65,16 +65,16 @@ describe('stock mark-gone behavior', () => { await data.markGone(data.entries[0]); - expect(useStockItemMock).toHaveBeenCalledWith({ addAlert, isConnected: false }, 'item-1'); + expect(markStockGoneMock).toHaveBeenCalledWith({ addAlert, isConnected: false }, 'item-1', 'consumed'); expect(data.entries).toEqual([]); expect(addAlert).toHaveBeenCalledWith({ type: 'success', - message: 'Flour was marked gone and removed from the list.', + message: 'Flour was marked used and removed from the list.', }); }); it('stock list grouped markGone removes item from grouped and flat collections', async () => { - useStockItemMock.mockResolvedValueOnce({ status: 'used' }); + markStockGoneMock.mockResolvedValueOnce({ status: 'ok' }); listGroupedStockEntriesMock.mockResolvedValueOnce([]); const addAlert = vi.fn(); const store = { addAlert, isConnected: true }; @@ -127,7 +127,7 @@ describe('stock mark-gone behavior', () => { expect(data.groupedEntries).toEqual([]); expect(addAlert).toHaveBeenCalledWith({ type: 'success', - message: 'Beans was marked gone and removed from the group.', + message: 'Beans was marked used and removed from the group.', }); expect(listGroupedStockEntriesMock).toHaveBeenCalledTimes(1); expect(listGroupedStockEntriesMock).toHaveBeenCalledWith(store, { expanded: 0 });