Align stock API with paginated backend and bump to v0.2.2
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2026-04-12 17:57:53 +02:00
parent ae8ad07d87
commit 39dd474813
9 changed files with 277 additions and 83 deletions
@@ -40,7 +40,7 @@ function createGroupedSummary() {
first_expire_date: '2026-04-25',
first_production_date: '2026-04-10',
items_count: 1,
items: [],
items: [{ id: 100 }],
},
];
}
@@ -164,12 +164,27 @@ describe('stock list grouped-first behavior', () => {
const data = stockListPageData({ isConnected: true, addAlert: vi.fn() });
await data.loadGroupedEntries({ expanded: 0, resetVisible: true });
expect(data.groupedEntries[0].items).toEqual([]);
expect(data.groupDisplayItems(data.groupedEntries[0])).toEqual([]);
expect(data.hasGroupedChildStubs(data.groupedEntries[0])).toBe(true);
await data.hydrateGroupedEntriesInBackground();
expect(data.groupedHydrated).toBe(true);
expect(data.groupedEntries[0].items).toHaveLength(1);
expect(data.groupDisplayItems(data.groupedEntries[0])).toHaveLength(1);
expect(data.hasGroupedChildStubs(data.groupedEntries[0])).toBe(false);
});
it('preserves hydrated child details when summary refresh returns id stubs', async () => {
const data = stockListPageData({ isConnected: true, addAlert: vi.fn() });
data.applyGroupedSummary(createGroupedSummary());
data.applyGroupedHydration(createGroupedExpanded());
expect(data.groupDisplayItems(data.groupedEntries[0])).toHaveLength(1);
data.applyGroupedSummary(createGroupedSummary());
expect(data.groupDisplayItems(data.groupedEntries[0])).toHaveLength(1);
});
it('memoizes filtered results and invalidates when filters change', () => {