// 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('Нажмите «+ Тренировка»'); });