diff --git a/tests/e2e/order_app.mjs b/tests/e2e/order_app.mjs index 7ba32dd..8deeef6 100644 --- a/tests/e2e/order_app.mjs +++ b/tests/e2e/order_app.mjs @@ -68,7 +68,8 @@ try { ] }, { id: 2, name: 'Food', products: [ { id: 12, name: 'Souvlaki', digital_description: 'Pork, pita, tzatziki', base_price: 4, digital_price: 4, digital_available: true, - sold_at: ['online_takeaway', 'online_delivery', 'online_preorder'], prices: { online_takeaway: 4, online_delivery: 4.2, online_preorder: 3.8 }, quick_options: [] }, + sold_at: ['online_takeaway', 'online_delivery', 'online_preorder'], prices: { online_takeaway: 4, online_delivery: 4.2, online_preorder: 3.8 }, quick_options: [], + allergens: { gluten: 'contains', milk: 'may_contain' } }, { id: 13, name: 'Soup of the day', base_price: 6, digital_available: false, sold_at: ['online_delivery'], prices: { online_delivery: 6 }, quick_options: [] }, ] }, ], @@ -104,6 +105,8 @@ try { && await page.getByTestId('service-takeaway').getAttribute('aria-checked') === 'true' && (await page.getByTestId('open-state').textContent()).includes('Open')) r.check('takeaway prices; the soup (delivery only) is not on the takeaway menu', (await product(11).getByTestId('price').textContent()).includes('2.50') && await product(13).count() === 0) + r.check('6.5: a dish says what it contains and may contain', ((await product(12).getByTestId('allergens').textContent().catch(() => '')).replace(/\s+/g, ' ')).includes('Contains: Gluten') + && (await product(12).getByTestId('allergens').textContent()).includes('May contain: Milk')) await page.getByTestId('service-delivery').click() r.check('delivery prices; the soup shows as sold out', (await product(11).getByTestId('price').textContent()).includes('2.80') && (await product(13).textContent()).includes('Sold out')) diff --git a/tests/e2e/qr_table.mjs b/tests/e2e/qr_table.mjs index 3b3bfc3..733bc23 100644 --- a/tests/e2e/qr_table.mjs +++ b/tests/e2e/qr_table.mjs @@ -81,7 +81,8 @@ try { const token5 = new URL(code5.url).searchParams.get('t') // 6.4: a dish translated to English (the venue types its menu in Greek) const firstDish = (await api('GET', '/api/products/')).find(p => !p.is_service_item && p.is_available && p.sold_at.includes('qr_table')) - await api('PUT', `/api/products/${firstDish.id}`, { body: { translations: { en: { name: 'E2E dish in English' } } } }) + await api('PUT', `/api/products/${firstDish.id}`, { body: { translations: { en: { name: 'E2E dish in English' } }, + allergens: { gluten: 'contains', sesame: 'may_contain' } } }) // 6.3 / 6.5: shown on the menu // the code reaches the cloud with the menu (pushed within seconds of the change) let seen = null const translated = m => m?.categories?.some(c => c.products.some(p => p.id === firstDish.id && p.names?.en === 'E2E dish in English')) @@ -118,6 +119,15 @@ try { r.check('scanning table 5: the menu says "Table 5" and lets them order', await page.getByTestId('table-banner').waitFor({ timeout: 15_000 }).then(() => true).catch(() => false) && (await page.getByTestId('table-banner').textContent()).includes(seen.table.label)) r.check('6.4: in English the menu shows the dish\'s English name', (await page.locator(`[data-testid="menu-product"][data-product="${d1.id}"]`).textContent()).includes('E2E dish in English')) + // 6.5: the dish opened big shows its allergens (contains gluten, may contain sesame), in English + await page.locator(`[data-testid="menu-product"][data-product="${d1.id}"]`).getByTestId('menu-name').click() + const sheet = page.getByTestId('product-sheet') + r.check('6.5: a dish shows its allergens: contains gluten, may contain sesame', await sheet.waitFor({ timeout: 5000 }).then(() => true).catch(() => false) + && await sheet.locator('[data-allergen="gluten"][data-level="contains"]').count() === 1 && await sheet.locator('[data-allergen="sesame"][data-level="may_contain"]').count() === 1 + && (await sheet.textContent()).includes('Gluten')) + await page.screenshot({ path: path.join(OUT, 'qr-table-dish.png') }) + await page.keyboard.press('Escape') + r.check('6.5: the card says what it contains', (await page.locator(`[data-testid="menu-product"][data-product="${d1.id}"]`).getByTestId('card-allergens').textContent().catch(() => '')).includes('Gluten')) await page.locator(`[data-testid="menu-product"][data-product="${d1.id}"]`).getByTestId('menu-add').click() await page.locator(`[data-testid="menu-product"][data-product="${d2.id}"]`).getByTestId('menu-add').click() await page.getByTestId('cart-button').click() @@ -139,11 +149,16 @@ try { r.check('6.4: the kitchen gets the name as typed (not the English one)', order?.items?.find(i => i.product_id === d1.id)?.product_name === firstDish.name, order?.items?.find(i => i.product_id === d1.id)?.product_name) const greek = await browser.newPage({ viewport: { width: 390, height: 844 } }) - await greek.addInitScript(() => localStorage.setItem('ot_lang', 'gr')) + await greek.addInitScript(() => localStorage.setItem('xenia-menu-lang', 'el')) await greek.goto(code5.url) const gCard = greek.locator(`[data-testid="menu-product"][data-product="${d1.id}"]`) r.check('6.4: in Greek the menu shows the name as typed', await gCard.waitFor({ timeout: 15_000 }).then(() => true).catch(() => false) && (await gCard.textContent()).includes(firstDish.digital_name || firstDish.name) && !(await gCard.textContent()).includes('E2E dish in English')) + r.check('6.5: …and the page itself in Greek (allergens too)', (await gCard.getByTestId('card-allergens').textContent().catch(() => '')).includes('Γλουτένη') + && await greek.getByTestId('lang-el').getAttribute('aria-pressed') === 'true') + await greek.getByTestId('lang-en').click() + r.check('6.5: the language switch changes the dish to English at once', (await gCard.textContent()).includes('E2E dish in English')) + await greek.screenshot({ path: path.join(OUT, 'qr-table-menu.png') }) await greek.close() r.check('…and in the kitchen (KDS)', (await api('GET', '/api/kds/orders')).orders.some(o => o.id === order?.id)) for (let i = 0; i < 20 && !events.slice(before).some(e => e.type === 'order_updated' && e.data?.table_id === t5.id); i++) await sleep(200) diff --git a/tests/e2e/run-all.mjs b/tests/e2e/run-all.mjs index 6d7bc87..e72eec1 100644 --- a/tests/e2e/run-all.mjs +++ b/tests/e2e/run-all.mjs @@ -20,6 +20,7 @@ const suites = [ ['unit: terminal (node --test)', 'npm', ['test', '--silent', '-w', 'terminal'], CS], ['lint: terminal', 'npm', ['run', 'lint', '--silent', '-w', 'terminal'], CS], ['unit: order-app (node --test)', 'npm', ['test', '--silent'], path.join(REPO, 'cloud-service', 'connect_frontend', 'order-app')], + ['unit: menu-app (node --test)', 'npm', ['test', '--silent'], path.join(REPO, 'cloud-service', 'connect_frontend', 'menu-app')], ['install.sh', 'node', ['install.mjs'], E2E], ['license (cloud + site)', PYTHON, ['license_e2e.py'], E2E], ['browser', 'node', ['browser.mjs'], E2E],