Merge branch 'main' into task/tptip-4
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 9s
deploy / deploy (pull_request) Successful in 26s

This commit is contained in:
peppa-bot 2026-11-17 12:44:00 +05:00
commit 9cbe964701
9 changed files with 51 additions and 5 deletions

View File

@ -42,3 +42,4 @@
- TPTIP-3: каталог /recipes.html (ru/kk/en), локальные фото assets; npm run build перед npm start; браузер npx playwright test. Сохранить маршруты recipes и сборку telemetry при объединении server.js/Dockerfile.
- TPTIP-40: numField(o.reqText) задаёт пометку; поля возраст/рост/вес — «нужно для расчёта норм», «обязательно» только у норм шага 2; CACHE tpt-v20-field-label.

View File

@ -550,7 +550,7 @@ function numField(label, o) {
const el = field(label, input, o.hint);
el.input = input;
if (o.what && o.required) {
el.querySelector('.lbl').append(h('span', { class: 'req' }, ' · обязательно'));
el.querySelector('.lbl').append(h('span', { class: 'req' }, o.reqText || ' · обязательно'));
input.setAttribute('aria-required', 'true');
input.addEventListener('blur', () => el.read());
input.addEventListener('input', () => { if (el.classList.contains('bad')) el.read(); });
@ -1230,9 +1230,9 @@ function viewStats() {
function calcFields(pr, hints) {
hints = hints || {};
const sex = selectField('Пол', [['m', 'Мужской'], ['f', 'Женский']], pr.sex);
const age = numField('Возраст, лет', { value: pr.age, placeholder: hints.age, required: true, int: true, min: 10, max: 100, what: 'возраст', hint: 'От 10 до 100 лет' });
const height = numField('Рост, см', { value: pr.height, placeholder: hints.height, required: true, min: 100, max: 250, what: 'рост', hint: 'От 100 до 250 см' });
const weight = numField('Вес, кг', { value: pr.weight, placeholder: hints.weight, required: true, min: 25, max: 400, what: 'вес', hint: 'От 25 до 400 кг' });
const age = numField('Возраст, лет', { value: pr.age, placeholder: hints.age, required: true, int: true, min: 10, max: 100, reqText: ' · нужно для расчёта норм', what: 'возраст', hint: 'От 10 до 100 лет' });
const height = numField('Рост, см', { value: pr.height, placeholder: hints.height, required: true, min: 100, max: 250, reqText: ' · нужно для расчёта норм', what: 'рост', hint: 'От 100 до 250 см' });
const weight = numField('Вес, кг', { value: pr.weight, placeholder: hints.weight, required: true, min: 25, max: 400, reqText: ' · нужно для расчёта норм', what: 'вес', hint: 'От 25 до 400 кг' });
const act = selectField('Активность', ACTIVITY, pr.activity);
return {
el: h('div', null, h('div', { class: 'grid2' }, sex, age), h('div', { class: 'grid2' }, height, weight), act),

View File

@ -0,0 +1 @@
numField получает опцию reqText (текст пометки); calcFields передаёт «нужно для расчёта норм». Проверка пустого поля и кнопка «Пропустить» не менялись; в «Настройки» поля те же. CACHE tpt-v20-field-label.

View File

@ -0,0 +1,4 @@
## Why
Рядом с полями возраста, роста и веса написано «обязательно», а выше сказано, что их можно пропустить.
## What Changes
Подпись у этих полей — «нужно для расчёта норм». «Обязательно» остаётся только на втором шаге (нормы), где без них нельзя нажать «Готово».

View File

@ -0,0 +1,14 @@
## ADDED Requirements
### Requirement: Подписи полей первого шага не противоречат «Пропустить»
Поля возраста, роста и веса SHALL быть подписаны «нужно для расчёта норм», а не «обязательно».
#### Scenario: Подписи на первом шаге
- **GIVEN** новый пользователь открыл мастер
- **WHEN** он смотрит на первый шаг
- **THEN** рядом с полями написано «нужно для расчёта норм»
- **AND** слова «обязательно» нет
#### Scenario: Пропуск
- **GIVEN** открыт первый шаг мастера
- **WHEN** пользователь нажимает «Пропустить»
- **THEN** открывается главный экран

View File

@ -0,0 +1,2 @@
- [x] Заменить подпись у полей первого шага
- [x] Тест и CACHE

View File

@ -23,3 +23,17 @@ TBD - created by archiving change tptip-34-field-error-text. Update Purpose afte
- **GIVEN** под полем возраста видна ошибка
- **WHEN** пользователь вводит 30
- **THEN** сообщение исчезает
### Requirement: Подписи полей первого шага не противоречат «Пропустить»
Поля возраста, роста и веса SHALL быть подписаны «нужно для расчёта норм», а не «обязательно».
#### Scenario: Подписи на первом шаге
- **GIVEN** новый пользователь открыл мастер
- **WHEN** он смотрит на первый шаг
- **THEN** рядом с полями написано «нужно для расчёта норм»
- **AND** слова «обязательно» нет
#### Scenario: Пропуск
- **GIVEN** открыт первый шаг мастера
- **WHEN** пользователь нажимает «Пропустить»
- **THEN** открывается главный экран

2
sw.js
View File

@ -1,5 +1,5 @@
// Сервис-воркер: приложение открывается без интернета (сначала сеть, при отсутствии — копия из кэша).
const CACHE = 'tpt-v19-wizard-why';
const CACHE = 'tpt-v20-field-label';
const FILES = ['./', 'index.html', 'gym-plan.i18n.js', 'manifest.webmanifest', 'icon.svg', 'recipes.html', 'recipes.css', 'recipes.js', 'recipes-core.js', 'recipes-status.i18n.js', 'recipes.data.json', 'recipes.i18n.json', 'telemetry.js', 'assets/oats.jpg', 'assets/chicken.jpg', 'assets/salad.jpg'];
self.addEventListener('install', e => { e.waitUntil(caches.open(CACHE).then(c => c.addAll(FILES)).then(() => self.skipWaiting())); });
self.addEventListener('activate', e => {

View File

@ -218,3 +218,13 @@ test('Сценарий: первый шаг объясняет, зачем да
btn(document, 'Набор').click();
assert.match(note(), /Выбрано: Набор/);
});
test('Сценарий: на первом шаге вместо «обязательно» подпись «нужно для расчёта норм», «Пропустить» открывает главный экран', t => {
const { dom, document } = open(); t.after(() => dom.window.close());
const marks = [...document.querySelectorAll('.sheet .req')].map(m => m.textContent);
assert.equal(marks.length, 3);
for (const m of marks) assert.match(m, /нужно для расчёта норм/);
assert.doesNotMatch(document.querySelector('.sheet').textContent, /обязательно/);
btn(document, 'Пропустить').click();
assert.equal(document.querySelector('.sheet'), null);
});