diff --git a/src/features/stock/stock-list-page.js b/src/features/stock/stock-list-page.js index a610561..a45ac93 100644 --- a/src/features/stock/stock-list-page.js +++ b/src/features/stock/stock-list-page.js @@ -2261,7 +2261,7 @@ export function stockListPageData(store) { ? `${item.name} was already out of stock and removed from the group.` : `${item.name} was marked gone and removed from the group.`, }); - this.refreshLoadedViewsInBackground().catch(() => {}); + this.loadGroupedEntries({ expanded: 0, background: true }).catch(() => {}); } catch (error) { this.editErrors[item.id] = error.message || 'Mark gone failed.'; } diff --git a/tests/features/stock/mark-gone.test.js b/tests/features/stock/mark-gone.test.js index 531bce2..3674b9d 100644 --- a/tests/features/stock/mark-gone.test.js +++ b/tests/features/stock/mark-gone.test.js @@ -2,6 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; const useStockItemMock = vi.fn(); const getStockEntryMock = vi.fn(); +const listGroupedStockEntriesMock = vi.fn(); vi.mock('../../../src/api/stock.js', () => ({ useStockItem: (...args) => useStockItemMock(...args), @@ -10,7 +11,7 @@ vi.mock('../../../src/api/stock.js', () => ({ lookupItemDetails: vi.fn(), patchStockItem: vi.fn(), listStockEntries: vi.fn(), - listGroupedStockEntries: vi.fn(), + listGroupedStockEntries: (...args) => listGroupedStockEntriesMock(...args), updateStockItem: vi.fn(), })); @@ -25,6 +26,7 @@ describe('stock mark-gone behavior', () => { beforeEach(() => { useStockItemMock.mockReset(); getStockEntryMock.mockReset(); + listGroupedStockEntriesMock.mockReset(); globalThis.window = { __loncApp: { navigate: vi.fn(), @@ -73,8 +75,11 @@ describe('stock mark-gone behavior', () => { it('stock list grouped markGone removes item from grouped and flat collections', async () => { useStockItemMock.mockResolvedValueOnce({ status: 'used' }); + listGroupedStockEntriesMock.mockResolvedValueOnce([]); const addAlert = vi.fn(); - const data = stockListPageData({ addAlert, isConnected: false }); + const store = { addAlert, isConnected: true }; + const data = stockListPageData(store); + data.groupedLoaded = true; data.groupedEntries = [ { @@ -124,5 +129,7 @@ describe('stock mark-gone behavior', () => { type: 'success', message: 'Beans was marked gone and removed from the group.', }); + expect(listGroupedStockEntriesMock).toHaveBeenCalledTimes(1); + expect(listGroupedStockEntriesMock).toHaveBeenCalledWith(store, { expanded: 0 }); }); });