feat(products): every menu text per language, the editor's language picker, service item dialog
- Alembic 0042: a `translations` column on every choice (groups, quick options, extras, ingredients, preference sets and choices; sub-choices and shared sub-sets in their JSON); the texts typed so far become the text in their language (Greek letters → el, else the venue's); the product's old quick map moves onto the quick options. API, catalogue bundle and the cloud's quick option names carry them; names are checked before anything is replaced. - Editor: a language picker beside the close button (Default = the venue's language, plus every menu language) drives every name and description, left and right; an empty language shows what is used instead as its placeholder. The shown name is the venue language's, else any (never mixed). - Choices: one name field; the shared controls at one height (heart red when on, several / compact… chips coloured when on, delete red on hover); "+ Preference" at the right end of the tab strip; preference groups made inside a preference. - Categories: the shared dropdown to add one; the category dialog per language. - The service item switch is gone: "New service item" opens its own small dialog. - UI: Dialog headerEnd; a toned toggle keeps its colour while pressed. - Tests: backend (choice names, migration 0042), access, editor logic, e2e. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+27
-5
@@ -1014,12 +1014,23 @@ try {
|
||||
await pRow.waitFor({ timeout: 15_000 })
|
||||
await pRow.getByTestId('product-edit').click()
|
||||
await page.getByTestId('product-editor').waitFor({ timeout: 10_000 })
|
||||
await page.getByTestId('add-category').selectOption(String(catB.id))
|
||||
await page.getByTestId('add-category').click() // 2026-11-21: the shared dropdown
|
||||
await page.getByRole('option', { name: catB.name, exact: true }).click()
|
||||
await page.getByTestId('allergen-gluten').click()
|
||||
await page.getByTestId('allergen-milk').click()
|
||||
await page.getByTestId('allergen-milk').click()
|
||||
await page.getByTestId('product-lang-el').click() // 2026-11-20: one name field, a language switch above it
|
||||
await page.getByTestId('translation-el-name').fill('E2E name in Greek') // 6.4: the test venue speaks English, so the other menu language is Greek
|
||||
// 2026-11-21: the language picker at the top drives every name field; "Default" = the venue's (English here)
|
||||
const pickLang = async label => { await page.getByTestId('product-lang').click(); await page.getByRole('option', { name: label }).first().click() }
|
||||
await pickLang(/^Greek/)
|
||||
await page.getByTestId('product-name').fill('Ε2Ε όνομα')
|
||||
await page.getByTestId('choices-tab-quick').click()
|
||||
await page.getByTestId('add-quick').click()
|
||||
await page.getByTestId('quick-name').last().fill('Ε2Ε μπέικον')
|
||||
await pickLang(/^Default \(English\)/)
|
||||
const nameEmptyInDefault = await page.getByTestId('product-name').inputValue() === '' && await page.getByTestId('quick-name').last().inputValue() === ''
|
||||
await page.getByTestId('product-name').fill('E2E name')
|
||||
await page.getByTestId('quick-name').last().fill('E2E bacon')
|
||||
r.check(`${pr} the language picker: a language without a text is empty (its placeholder shows what is used instead)`, nameEmptyInDefault)
|
||||
r.check(`${pr} the editor lists both categories, the first one main; gluten "contains", milk "may contain"`,
|
||||
await page.locator(`[data-testid="product-category"][data-id="${catA.id}"][data-main="true"]`).count() === 1
|
||||
&& await page.locator(`[data-testid="product-category"][data-id="${catB.id}"][data-main="false"]`).count() === 1
|
||||
@@ -1030,8 +1041,19 @@ try {
|
||||
const savedP = (await api('GET', '/api/products/?all=true', { token: boss })).find(p => p.id === prodP.id)
|
||||
r.check(`${pr} saved: listed in both, the main one kept, its allergens`, JSON.stringify(savedP.category_ids) === JSON.stringify([catA.id, catB.id])
|
||||
&& savedP.primary_category_id === catA.id && JSON.stringify(savedP.allergens) === JSON.stringify({ gluten: 'contains', milk: 'may_contain' }), JSON.stringify([savedP.category_ids, savedP.allergens]))
|
||||
r.check(`${pr} 6.4: its name for the other menu language is saved; the name itself is unchanged`, savedP.translations?.el?.name === 'E2E name in Greek' && savedP.name === prodP.name,
|
||||
JSON.stringify(savedP.translations))
|
||||
const quickP = savedP.quick_options.find(q => q.name === 'E2E bacon')
|
||||
r.check(`${pr} every text per language: the name and a quick option in Greek and in the default (English, which is shown)`,
|
||||
JSON.stringify(savedP.translations) === JSON.stringify({ el: { name: 'Ε2Ε όνομα' }, en: { name: 'E2E name' } }) && savedP.name === 'E2E name'
|
||||
&& JSON.stringify(quickP?.translations) === JSON.stringify({ el: 'Ε2Ε μπέικον', en: 'E2E bacon' }), JSON.stringify([savedP.name, savedP.translations, savedP.quick_options]))
|
||||
// a service item: its own small dialog (the switch is gone)
|
||||
await page.getByTestId('service-new').click()
|
||||
await page.getByTestId('service-dialog').waitFor({ timeout: 8000 })
|
||||
await page.getByTestId('service-name').fill('E2E cutlery')
|
||||
await page.getByTestId('service-save').click()
|
||||
await page.getByTestId('service-dialog').waitFor({ state: 'detached', timeout: 8000 }).catch(() => {})
|
||||
let svc = null
|
||||
for (let i = 0; i < 20 && !svc; i++) { await sleep(250); svc = (await api('GET', '/api/products/?all=true', { token: boss })).find(p => p.name === 'E2E cutlery') }
|
||||
r.check(`${pr} "New service item" makes a service item, its name in the default language`, svc?.is_service_item === true && svc.translations?.en?.name === 'E2E cutlery', JSON.stringify(svc))
|
||||
await page.getByTestId(`category-${catB.id}`).click()
|
||||
const inB = page.locator(`[data-testid="product-group"][data-category="${catB.id}"] [data-testid="product-row"][data-id="${prodP.id}"]`)
|
||||
r.check(`${pr} it shows in the second category too, marked "also in" the first`, await inB.waitFor({ timeout: 8000 }).then(() => true).catch(() => false)
|
||||
|
||||
Reference in New Issue
Block a user