treker-po-trenirovkam-i-pit.../tests/browser/skip.spec.js
Peppa b523bf67a4
All checks were successful
peppa/lint lint: success за 0с
peppa/test test: success за 1с
peppa/build build: success за 0с
ci / checks (pull_request) Successful in 8s
deploy / deploy (pull_request) Successful in 9s
TPTIP-45: verify skipped welcome flow on mobile and archive specs
2026-11-17 12:54:44 +05:00

66 lines
3.1 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({ 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();
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' });
});