treker-po-trenirovkam-i-pit.../tests/browser/skip.spec.js
Peppa 7e9495896c
All checks were successful
peppa/lint lint: success за 0с
peppa/test test: success за 2с
peppa/build build: success за 0с
ci / checks (pull_request) Successful in 9s
deploy / deploy (pull_request) Successful in 18s
TPTIP-45: align flow checks with updated profile defaults
2026-11-17 12:56:42 +05:00

68 lines
3.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.

const { test, expect } = require('@playwright/test');
test.use({ baseURL: 'http://127.0.0.1:3094', viewport: { width: 375, height: 740 }, locale: 'ru-RU' });
async function skip(page) {
await page.goto('/');
await page.getByRole('button', { name: 'Пропустить', exact: true }).click();
await expect(page.locator('.sheet')).toHaveCount(0);
}
const sections = [
['Питание', 'Итог дня'],
['Тренировки', 'Пока нет ни одной тренировки'],
['Тело', 'Вес'],
['Статистика', 'Калории по дням'],
['Настройки', 'Калькулятор нормы']
];
test('Сценарий: Разделы после пропуска', async ({ page }) => {
const errors = [];
page.on('pageerror', e => errors.push(e.message));
await skip(page);
await expect(page.locator('.datenav')).toBeVisible();
await expect(page.locator('#tabs')).toBeVisible();
await expect(page.locator('[data-norms-pending]')).toContainText('возраст, рост и вес');
await expect(page.locator('#toast')).toBeHidden();
await page.screenshot({ path: 'docs/screens/tptip-45-skipped.png' });
for (const [name, content] of sections) {
await page.locator('#tabs').getByRole('button', { name, exact: false }).click();
await expect(page.locator('#view')).toContainText(content);
await expect(page.locator('#tabs button[aria-current="page"]')).toContainText(name);
await expect(page.locator('#tabs')).toBeVisible();
expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(375);
}
expect(errors).toEqual([]);
});
test('Сценарий: Сохранение без данных', async ({ page }) => {
await skip(page);
await page.locator('[data-norms-open]').click();
await page.getByRole('button', { name: 'Сохранить', exact: true }).click();
await expect(page.locator('#view')).toContainText('Заполните это поле');
await expect(page.locator('#view input').first()).toBeFocused();
await page.locator('#tabs').getByRole('button', { name: 'Главная', exact: false }).click();
await expect(page.locator('[data-norms-pending]')).toBeVisible();
});
test('Сценарий: Повторное открытие после сохранения', async ({ page }) => {
await skip(page);
await page.locator('[data-norms-open]').click();
await page.locator('#view select').nth(0).selectOption('m');
await page.locator('#view select').nth(1).selectOption('1.375');
const fields = page.locator('#view input');
for (const [i, value] of ['40', '170', '65'].entries()) {
await expect(fields.nth(i)).toHaveValue('');
await fields.nth(i).fill(value);
}
await page.getByRole('button', { name: 'Сохранить', exact: true }).click();
await page.locator('#tabs').getByRole('button', { name: 'Главная', exact: false }).click();
await page.reload();
await expect(page.locator('.sheet')).toHaveCount(0);
await expect(page.locator('[data-norms-pending]')).toHaveCount(0);
for (const [i, value] of ['0 из 2087', '0 из 117', '0 из 58', '0 из 274', '0 из 1950'].entries()) {
await expect(page.locator('.rings [data-amount]').nth(i)).toHaveText(value);
}
await page.screenshot({ path: 'docs/screens/tptip-45-saved.png' });
});