Reduce grouped mark-gone refresh to summary fetch only
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -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.';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user