treker-po-trenirovkam-i-pit.../tests/browser/five-sections.spec.js
Peppa 5905795287
All checks were successful
peppa/lint lint: success за 1с
peppa/test test: success за 1с
peppa/build build: success за 0с
ci / checks (pull_request) Successful in 10s
deploy / deploy (pull_request) Successful in 16s
TPTIP-70: подсказки в пустых разделах и проверка пяти разделов
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-18 00:58:23 +05:00

38 lines
2.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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