treker-po-trenirovkam-i-pit.../tests/browser/goal-menu-plan.spec.js

36 lines
1.9 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 { randomUUID } = require('node:crypto');
const { test, expect } = require('@playwright/test');
test('Меню и упражнения по дням обновляются после смены цели', async ({ page }) => {
await page.goto('/?lang=ru');
await page.locator('[data-welcome-next]').click();
const createPlan = page.getByRole('button', { name: 'Создать меню и план тренировок' });
await createPlan.click();
await expect(page.getByText(/Заполните возраст, рост, вес, пол, активность и цель/)).toBeVisible();
await page.locator('#field-username').fill('goal' + randomUUID().slice(0, 8));
await page.locator('#field-password').fill('test-goal-plan-123');
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 page.locator('#field-goal').selectOption('lose');
await page.locator('button[type=submit]').click();
await expect(page.locator('#field-password')).toHaveCount(0);
await createPlan.click();
const days = page.locator('[data-goal-plan-day]');
await expect(days).toHaveCount(4);
await expect(days.first()).toContainText('Жим гантелей лёжа');
await expect(days.first()).toContainText('2 × 10');
const firstBreakfast = days.first().getByText(/овсянка с йогуртом/);
const originalPortion = await firstBreakfast.textContent();
await page.locator('#field-goal').selectOption('gain');
await page.locator('button[type=submit]').click();
await expect(page.locator('#goal-plan-content')).toBeHidden();
await createPlan.click();
await expect(days.first()).toContainText('4 × 10');
await expect(firstBreakfast).not.toHaveText(originalPortion);
});