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
+4 -1
View File
@@ -68,7 +68,8 @@ try {
] }, ] },
{ id: 2, name: 'Food', products: [ { id: 2, name: 'Food', products: [
{ id: 12, name: 'Souvlaki', digital_description: 'Pork, pita, tzatziki', base_price: 4, digital_price: 4, digital_available: true, { 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: [] }, { 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')) && 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', 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) (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() 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') 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')) && (await product(13).textContent()).includes('Sold out'))
+17 -2
View File
@@ -81,7 +81,8 @@ try {
const token5 = new URL(code5.url).searchParams.get('t') const token5 = new URL(code5.url).searchParams.get('t')
// 6.4: a dish translated to English (the venue types its menu in Greek) // 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')) 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) // the code reaches the cloud with the menu (pushed within seconds of the change)
let seen = null 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')) 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) 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)) && (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')) 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="${d1.id}"]`).getByTestId('menu-add').click()
await page.locator(`[data-testid="menu-product"][data-product="${d2.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() 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, 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) order?.items?.find(i => i.product_id === d1.id)?.product_name)
const greek = await browser.newPage({ viewport: { width: 390, height: 844 } }) 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) await greek.goto(code5.url)
const gCard = greek.locator(`[data-testid="menu-product"][data-product="${d1.id}"]`) 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) 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')) && (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() await greek.close()
r.check('…and in the kitchen (KDS)', (await api('GET', '/api/kds/orders')).orders.some(o => o.id === order?.id)) 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) 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)
+1
View File
@@ -20,6 +20,7 @@ const suites = [
['unit: terminal (node --test)', 'npm', ['test', '--silent', '-w', 'terminal'], CS], ['unit: terminal (node --test)', 'npm', ['test', '--silent', '-w', 'terminal'], CS],
['lint: terminal', 'npm', ['run', 'lint', '--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: 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], ['install.sh', 'node', ['install.mjs'], E2E],
['license (cloud + site)', PYTHON, ['license_e2e.py'], E2E], ['license (cloud + site)', PYTHON, ['license_e2e.py'], E2E],
['browser', 'node', ['browser.mjs'], E2E], ['browser', 'node', ['browser.mjs'], E2E],