Reduce grouped mark-gone refresh to summary fetch only
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2026-04-12 23:00:06 +02:00
parent 065eed9769
commit 50e147b079
2 changed files with 10 additions and 3 deletions
+1 -1
View File
@@ -2261,7 +2261,7 @@ export function stockListPageData(store) {
? `${item.name} was already out of stock and removed from the group.` ? `${item.name} was already out of stock and removed from the group.`
: `${item.name} was marked gone 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) { } catch (error) {
this.editErrors[item.id] = error.message || 'Mark gone failed.'; this.editErrors[item.id] = error.message || 'Mark gone failed.';
} }
+9 -2
View File
@@ -2,6 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
const useStockItemMock = vi.fn(); const useStockItemMock = vi.fn();
const getStockEntryMock = vi.fn(); const getStockEntryMock = vi.fn();
const listGroupedStockEntriesMock = vi.fn();
vi.mock('../../../src/api/stock.js', () => ({ vi.mock('../../../src/api/stock.js', () => ({
useStockItem: (...args) => useStockItemMock(...args), useStockItem: (...args) => useStockItemMock(...args),
@@ -10,7 +11,7 @@ vi.mock('../../../src/api/stock.js', () => ({
lookupItemDetails: vi.fn(), lookupItemDetails: vi.fn(),
patchStockItem: vi.fn(), patchStockItem: vi.fn(),
listStockEntries: vi.fn(), listStockEntries: vi.fn(),
listGroupedStockEntries: vi.fn(), listGroupedStockEntries: (...args) => listGroupedStockEntriesMock(...args),
updateStockItem: vi.fn(), updateStockItem: vi.fn(),
})); }));
@@ -25,6 +26,7 @@ describe('stock mark-gone behavior', () => {
beforeEach(() => { beforeEach(() => {
useStockItemMock.mockReset(); useStockItemMock.mockReset();
getStockEntryMock.mockReset(); getStockEntryMock.mockReset();
listGroupedStockEntriesMock.mockReset();
globalThis.window = { globalThis.window = {
__loncApp: { __loncApp: {
navigate: vi.fn(), 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 () => { it('stock list grouped markGone removes item from grouped and flat collections', async () => {
useStockItemMock.mockResolvedValueOnce({ status: 'used' }); useStockItemMock.mockResolvedValueOnce({ status: 'used' });
listGroupedStockEntriesMock.mockResolvedValueOnce([]);
const addAlert = vi.fn(); const addAlert = vi.fn();
const data = stockListPageData({ addAlert, isConnected: false }); const store = { addAlert, isConnected: true };
const data = stockListPageData(store);
data.groupedLoaded = true;
data.groupedEntries = [ data.groupedEntries = [
{ {
@@ -124,5 +129,7 @@ describe('stock mark-gone behavior', () => {
type: 'success', type: 'success',
message: 'Beans was marked gone and removed from the group.', message: 'Beans was marked gone and removed from the group.',
}); });
expect(listGroupedStockEntriesMock).toHaveBeenCalledTimes(1);
expect(listGroupedStockEntriesMock).toHaveBeenCalledWith(store, { expanded: 0 });
}); });
}); });