Compare commits

..

No commits in common. "b6c89e548da79fb68db9ed1fdebb26d2ab74d501" and "35278053a71ff84e763d772f8925841de1070a5e" have entirely different histories.

3 changed files with 8 additions and 22 deletions

View file

@ -2771,16 +2771,9 @@ button:active, .btn:active, .meal-card-main:active, .dagboek-item:active, .food-
searchObserver = new IntersectionObserver((entries) => {
if (entries[0].isIntersecting) {
// Load up to 3 batches at once when user scrolls fast
// This keeps the sentinel pushed far ahead of the viewport
let batchesLoaded = 0;
const maxBatches = 3;
while (batchesLoaded < maxBatches && searchVisibleCount < allItems.length) {
appendSearchBatch(allItems);
batchesLoaded++;
}
appendSearchBatch(allItems);
}
}, { rootMargin: '1200px' });
}, { rootMargin: '200px' });
searchObserver.observe(sentinel);
}

View file

@ -2771,16 +2771,9 @@ button:active, .btn:active, .meal-card-main:active, .dagboek-item:active, .food-
searchObserver = new IntersectionObserver((entries) => {
if (entries[0].isIntersecting) {
// Load up to 3 batches at once when user scrolls fast
// This keeps the sentinel pushed far ahead of the viewport
let batchesLoaded = 0;
const maxBatches = 3;
while (batchesLoaded < maxBatches && searchVisibleCount < allItems.length) {
appendSearchBatch(allItems);
batchesLoaded++;
}
appendSearchBatch(allItems);
}
}, { rootMargin: '1200px' });
}, { rootMargin: '200px' });
searchObserver.observe(sentinel);
}

View file

@ -456,14 +456,14 @@ test.describe('Karby Eetdagboek', () => {
// Sentinel should exist (there are more than 50 items)
await expect(page.locator('#searchSentinel')).toBeAttached({ timeout: 3000 });
// Scroll sentinel into view to trigger next batches (now loads 3 at once)
// Scroll sentinel into view to trigger next batch
await page.locator('#searchSentinel').scrollIntoViewIfNeeded();
await page.waitForTimeout(1200);
await page.waitForTimeout(800);
// Now more items should be rendered (up to 3 batches of 50)
// Now more items should be rendered
const afterScrollCount = await page.locator('.food-item').count();
expect(afterScrollCount).toBeGreaterThan(initialCount);
expect(afterScrollCount).toBeLessThanOrEqual(200); // max 4 batches total (50 + 3×50)
expect(afterScrollCount).toBeLessThanOrEqual(100); // 2nd page = 100 max
});
test('infinite scroll: search query resets pagination', async ({ page }) => {