test(e2e): the QR menu's new look: allergens, the language switch; the order app's allergens (platform-v2 step 6.5)

run-all also runs the menu app's unit tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 11:27:10 +02:00
co-authored by Claude Opus 5.5
parent e395d99704
commit c43dc8b55b
3 changed files with 22 additions and 3 deletions
+17 -2
View File
@@ -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)