diff --git a/index.html b/index.html index 31a7c4b..095bf83 100644 --- a/index.html +++ b/index.html @@ -1080,7 +1080,7 @@ function viewWorkouts() { w.type === 'strength' && w.exercises.length ? h('div', { class: 'small muted' }, w.exercises.map(e => e.name + ' ' + e.sets.map(s => s.reps + '×' + fmt(s.weight)).join(', ')).join(' | ')) : null, w.note ? h('div', { class: 'small' }, '📝 ' + w.note) : null), h('button', { class: 'ghost icon', 'aria-label': 'Удалить тренировку', onclick: () => delWorkout(w) }, '🗑'))) : - h('div', { class: 'empty' }, db.workouts.length ? 'Нет тренировок такого типа' : 'Пока нет ни одной тренировки'))); + h('div', { class: 'empty' }, db.workouts.length ? 'Нет тренировок такого типа' : 'Пока нет ни одной тренировки. Нажмите «+ Тренировка», чтобы добавить первую.'))); } function delWorkout(w) { confirmBox('Удалить тренировку от ' + longDate(w.date) + '?', 'Удалить', () => { db.workouts = db.workouts.filter(x => x.id !== w.id); save(); render(); }); @@ -1229,7 +1229,8 @@ function viewStats() { h('div', { class: 'stat' }, h('span', { class: 'muted small' }, 'Дней с записью еды'), h('b', null, st.loggedDays + ' из ' + days)), h('div', { class: 'stat' }, h('span', { class: 'muted small' }, 'Шаги в день'), h('b', null, st.avgSteps == null ? '—' : fmtK(st.avgSteps))), h('div', { class: 'stat' }, h('span', { class: 'muted small' }, 'Сон, часов'), h('b', null, fmt(st.avgSleep)))), - h('p', { class: 'small muted' }, 'Среднее считается по дням, когда еда записана.')), + h('p', { class: 'small muted' }, 'Среднее считается по дням, когда еда записана.'), + st.loggedDays === 0 && !st.workouts ? h('p', { 'data-stats-hint': '', class: 'small' }, 'Пока нечего считать. Запишите еду на вкладке «Питание» или тренировку на вкладке «Тренировки» — здесь появятся средние значения и графики.') : null), h('div', { class: 'card' }, h('h3', null, 'Калории по дням'), barChart(st.days, db.settings.kcal)), h('div', { class: 'card' }, h('h3', null, 'Вес, кг'), lineChart(weightSeries(db).filter(p => p.x >= st.days[0].date), 'кг')), h('div', { class: 'card' }, h('h3', null, '🏆 Личные рекорды'), personalBests(db).length diff --git a/tests/browser/five-sections.spec.js b/tests/browser/five-sections.spec.js new file mode 100644 index 0000000..2909ed8 --- /dev/null +++ b/tests/browser/five-sections.spec.js @@ -0,0 +1,37 @@ +// TPTIP-70: все пять разделов нижнего меню открываются без пустых экранов и ошибок. +const { test, expect } = require('@playwright/test'); + +test.use({ baseURL: 'http://127.0.0.1:3094', viewport: { width: 375, height: 740 }, locale: 'ru-RU' }); + +const SECTIONS = ['Питание', 'Тренировки', 'Тело', 'Статистика', 'Настройки']; + +test('Сценарий: Каждый раздел открывается, показывает текст и не даёт ошибок', async ({ page }) => { + const errors = []; + page.on('pageerror', e => errors.push(e.message)); + page.on('console', m => { if (m.type() === 'error') errors.push(m.text()); }); + await page.goto('/'); + await page.locator('.sheet select').first().selectOption('m'); + await page.locator('.sheet select').last().selectOption('1.375'); + const fields = page.locator('.sheet input'); + for (const [i, value] of ['40', '170', '65'].entries()) await fields.nth(i).fill(value); + await page.getByRole('button', { name: 'Далее', exact: true }).click(); + await page.getByRole('button', { name: 'Готово', exact: true }).click(); + await expect(page.locator('.sheet')).toHaveCount(0); + for (const name of SECTIONS) { + await page.locator('#tabs button', { hasText: name }).click(); + await expect(page.locator('#tabs button[aria-current="page"]')).toContainText(name); + const text = (await page.locator('main, #app, body').first().innerText()).trim(); + expect(text.length, name + ': есть текст').toBeGreaterThan(40); + expect(text, name + ': без ошибки').not.toMatch(/undefined|NaN|\[object|Error/); + } + expect(errors).toEqual([]); +}); + +test('Сценарий: В пустой статистике и тренировках сказано, что делать', async ({ page }) => { + await page.goto('/'); + await page.getByRole('button', { name: 'Пропустить', exact: true }).first().click().catch(() => {}); + await page.locator('#tabs button', { hasText: 'Статистика' }).click(); + await expect(page.locator('[data-stats-hint]')).toContainText('Запишите еду'); + await page.locator('#tabs button', { hasText: 'Тренировки' }).click(); + await expect(page.locator('.empty')).toContainText('Нажмите «+ Тренировка»'); +});