diff --git a/docker/index.html b/docker/index.html index 2b5a7bf..ef80903 100644 --- a/docker/index.html +++ b/docker/index.html @@ -3276,6 +3276,10 @@ button:active, .btn:active, .meal-card-main:active, .dagboek-item:active, .food- document.body.appendChild(overlay); document.body.style.overflow = 'hidden'; + function closeDialog() { + overlay.classList.add('closing'); + setTimeout(() => { overlay.remove(); document.body.style.overflow = ''; }, 280); + } overlay.querySelector('#portieEditClose').addEventListener('click', closeDialog); overlay.addEventListener('click', (e) => { if (e.target === overlay) closeDialog(); }); diff --git a/index.html b/index.html index 2b5a7bf..ef80903 100644 --- a/index.html +++ b/index.html @@ -3276,6 +3276,10 @@ button:active, .btn:active, .meal-card-main:active, .dagboek-item:active, .food- document.body.appendChild(overlay); document.body.style.overflow = 'hidden'; + function closeDialog() { + overlay.classList.add('closing'); + setTimeout(() => { overlay.remove(); document.body.style.overflow = ''; }, 280); + } overlay.querySelector('#portieEditClose').addEventListener('click', closeDialog); overlay.addEventListener('click', (e) => { if (e.target === overlay) closeDialog(); }); diff --git a/tests/e2e.spec.js b/tests/e2e.spec.js index 847634c..7a1dd39 100644 --- a/tests/e2e.spec.js +++ b/tests/e2e.spec.js @@ -393,4 +393,48 @@ test.describe('Karby Eetdagboek', () => { } }); + test('portie-edit dialog: single ingredient portion change saves and closes', async ({ page }) => { + // Add a loose ingredient to the diary first + await page.goto(BASE); + await page.locator('.search-input').fill('brood'); + await page.waitForTimeout(800); + await page.locator('.food-item').first().click(); + await page.waitForTimeout(500); + + // Click "Toevoegen aan eetmoment" → opens addMealModal + await page.locator('#detailAddBtn').click(); + await page.waitForTimeout(500); + + // Confirm adding to diary (default portie=100g, default eetmoment) + await page.locator('#addMealSubmit').click(); + await page.waitForTimeout(800); + + // Should now be on dagboek tab + // Find the portion display for a single ingredient (no data-mi attribute) + const portionSpan = page.locator('[data-action="edit-portie"]:not([data-mi])').first(); + await expect(portionSpan).toBeVisible({ timeout: 5000 }); + await portionSpan.click(); + await page.waitForTimeout(500); + + // Verify the portion edit dialog opened + const editInput = page.locator('#portieEditInput'); + await expect(editInput).toBeVisible({ timeout: 3000 }); + + // Verify preview shows initial carbs + const preview = page.locator('#portieEditPreview'); + await expect(preview).toBeVisible(); + + // Change the portion to 200g + await editInput.fill('200'); + await editInput.dispatchEvent('input'); + await page.waitForTimeout(300); + + // Click save + await page.locator('#portieSaveBtn').click(); + await page.waitForTimeout(500); + + // Dialog should be gone (removed from DOM after closing animation) + await expect(page.locator('#portieEditInput')).not.toBeAttached({ timeout: 3000 }); + }); + });