TPTIP-29: тест выбора блюда через «+ Рецепт», память проекта
All checks were successful
peppa/lint lint: success за 0с
peppa/test test: success за 1с
peppa/build build: success за 0с
ci / checks (pull_request) Successful in 8s
deploy / deploy (pull_request) Successful in 7s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Peppa 2026-11-17 12:10:16 +05:00
parent 661b3b025e
commit e0c4b4ef64
2 changed files with 15 additions and 0 deletions

View File

@ -23,6 +23,7 @@
- TPTIP-26: тексты ошибок мастера строит wizardError(o, raw, err) в numField (поля с what): «Укажите/Проверьте <what>: … Введите число <hint>.»; нормы второго шага (normFields) тоже с what/hint и читают все поля; focusFirstError(body) на «Далее»/«Готово»; CACHE tpt-v9-wizard-errors.
- TPTIP-27: рецепт в recipeView раскрывается кнопкой [data-recipe-toggle] (ol[data-steps] hidden), без шагов — [data-no-recipe]; CACHE tpt-v10-recipe-steps.
- TPTIP-28: подсказка пустых колец ([data-empty-hint] в viewToday) скрыта, если есть еда, вода или тренировка; CACHE tpt-v11-empty-hint.
- TPTIP-29: «Выбрать» (chooseRecipe) уже полностью работает: тост, КБЖУ в приёме пищи, кольца, вопрос при повторе; закреплено тестами в tests/dish-card.test.js, включая путь через «+ Рецепт».
## Грабли
- На 17.11.2026 origin/main содержал только bootstrap, приложение было в task/tptip-8, сервер — в task/tptip-6; task/tptip-5 включает обе зависимости. При объединении server.js и Dockerfile использована версия TPTIP-6.
- TPTIP-22: ring(label,fact,target,unit,color) — единица полностью («килокалории/граммы/миллилитры») под названием, внутри кольца «из N»; CACHE sw.js tpt-v5-rings.

View File

@ -173,3 +173,17 @@ test('Сценарий: подсказка про пустые кольца го
const { dom, document } = open(); t.after(() => dom.window.close());
assert.match(document.querySelector('[data-empty-hint]').textContent, /выберите блюдо.*добавьте тренировку/);
});
test('Сценарий: «Выбрать» в списке «+ Рецепт» тоже добавляет блюдо в приём пищи и кольца', t => {
const { dom, document, errors } = open(); t.after(() => dom.window.close());
const ringsBefore = document.querySelector('.rings').textContent;
[...document.querySelectorAll('button')].find(b => b.textContent === '+ Рецепт').click();
const sheetCards = [...document.querySelectorAll('.item.dish')].filter(c => c.querySelector('b').textContent === 'Греческий салат');
assert.ok(sheetCards.length >= 1, 'в списке нет блюда');
[...sheetCards[sheetCards.length - 1].querySelectorAll('button')].find(b => b.textContent === 'Выбрать').click();
assert.deepEqual(errors, []);
assert.match(document.getElementById('toast').textContent, /Греческий салат добавлен в приём пищи/);
assert.notEqual(document.querySelector('.rings').textContent, ringsBefore);
const saved = JSON.parse(dom.window.localStorage.getItem('tpt.v1'));
assert.equal(saved.meals.filter(m => m.name === 'Греческий салат').length, 1);
});