treker-po-trenirovkam-i-pit.../tests/browser/public-menu-plan.spec.js
peppa-bot 15c2e95f9f
All checks were successful
peppa/lint lint: success за 1с
peppa/test test: success за 2с
peppa/build build: success за 1с
ci / checks (pull_request) Successful in 30s
deploy / deploy (pull_request) Successful in 31s
TPTIP-89: проверить расчёт на телефоне и архивировать спецификацию
2026-11-25 12:47:37 +00:00

57 lines
2.8 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.

const { test, expect } = require('@playwright/test');
const translations = require('../../profile/i18n.json');
test.use({ viewport: { width: 360, height: 640 }, isMobile: true, hasTouch: true });
for (const lang of ['ru', 'kk', 'en']) {
test(`Расчёт меню и плана с приветствия (${lang})`, async ({ page }) => {
const text = translations[lang];
const writes = [];
page.on('request', request => {
if (request.method() !== 'GET') writes.push(request.url());
});
await page.goto('/?lang=' + lang);
const open = page.getByRole('button', { name: text.createGoalPlan, exact: true });
await expect(open).toBeInViewport({ ratio: 1 });
await page.locator('#welcome-goal').selectOption('lose');
await open.click();
await expect(page.getByRole('heading', { level: 1 })).toHaveText(text.goalPlanHeading);
await expect(page.locator('#field-goal')).toHaveValue('lose');
await expect(page.locator('#field-password, #field-username')).toHaveCount(0);
await page.locator('#field-height').fill('175');
await page.locator('#field-weight').fill('75');
await page.locator('#field-age').fill('30');
await page.locator('#field-sex').selectOption('male');
await page.locator('#field-activity').selectOption('1.375');
await open.click();
const days = page.locator('[data-goal-plan-day]');
await expect(days).toHaveCount(4);
await expect(days.first()).toContainText(`${text.breakfast} · 458 ${text.grams}`);
await expect(days.first()).toContainText(text.goalPlanDose.replace('{sets}', '2').replace('{reps}', '10'));
await page.locator('#field-goal').selectOption('gain');
await expect(days).toHaveCount(0);
await open.click();
await expect(days.first()).toContainText(text.goalPlanDose.replace('{sets}', '4').replace('{reps}', '10'));
await expect(days.first()).not.toContainText(`${text.breakfast} · 458 ${text.grams}`);
expect(writes).toEqual([]);
expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(360);
await page.getByRole('button', { name: text.publicPlanBack, exact: true }).click();
await page.locator('[data-welcome-skip]').click();
await expect(open).toBeVisible();
});
}
test('Рост вне диапазона не даёт рассчитать меню и план', async ({ page }) => {
await page.goto('/?lang=ru');
const create = page.getByRole('button', { name: translations.ru.createGoalPlan, exact: true });
await create.click();
const height = page.locator('#field-height');
await height.fill('5');
await create.click();
await expect(height).toBeFocused();
await expect(page.locator('#field-height-error')).toHaveText(translations.ru.errors.height);
await expect(page.locator('[data-goal-plan-day]')).toHaveCount(0);
});