treker-po-trenirovkam-i-pit.../tests/browser/russian-after-next.spec.js
Peppa dfd8fe9cf1
All checks were successful
deploy / deploy (pull_request) Successful in 16s
peppa/lint lint: success за 0с
peppa/test test: success за 1с
peppa/build build: success за 1с
ci / checks (pull_request) Successful in 22s
TPTIP-74: проверка русского и английского текста регистрации и входа
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-18 19:40:44 +05:00

49 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.

const { test, expect } = require('@playwright/test');
const fs = require('node:fs');
test.use({ locale: 'en-US', viewport: { width: 360, height: 740 } });
const ALLOWED_LATIN = /^(RU|EN|KK|ru|en|kk)$/;
async function screenText(page) {
return page.locator('body').innerText();
}
async function optionsText(page) {
return page.locator('option').allInnerTexts();
}
function latinWords(text) {
return (text.match(/[A-Za-z]{2,}/g) || []).filter(w => !ALLOWED_LATIN.test(w));
}
async function save(page, name) {
fs.mkdirSync('docs/screens', { recursive: true });
await page.screenshot({ path: `docs/screens/tptip-74-${name}.png`, fullPage: true });
}
test('RU после «Далее»: регистрация и вход, включая ошибки, без английских слов', async ({ page }) => {
await page.goto('/');
await page.locator('[data-welcome-next]').click();
await expect(page.locator('select.lang')).toHaveValue('ru');
// Ошибки у полей: отправляем пустую форму
await page.getByRole('button', { name: 'Создать учётную запись', exact: true }).click();
const reg = (await screenText(page)) + (await optionsText(page)).join(' ');
expect(latinWords(reg)).toEqual([]);
expect(await page.locator('[role="alert"], .field-error, .error').count()).toBeGreaterThan(0);
await save(page, 'register-ru');
await page.getByRole('button', { name: 'Уже есть учётная запись? Войти', exact: true }).click();
await page.getByRole('button', { name: 'Войти', exact: true }).last().click();
expect(latinWords(await screenText(page))).toEqual([]);
await save(page, 'login-ru');
});
test('EN: тот же экран регистрации и входа полностью английский', async ({ page }) => {
await page.goto('/');
await page.locator('[data-welcome-next]').click();
await page.locator('select.lang').selectOption('en');
await page.getByRole('button', { name: 'Create account', exact: true }).first().click();
const reg = (await screenText(page)) + (await optionsText(page)).join(' ');
expect(reg).not.toMatch(/[А-Яа-яЁё]/);
await save(page, 'register-en');
await page.getByRole('button', { name: /Already have an account/ }).click();
expect(await screenText(page)).not.toMatch(/[А-Яа-яЁё]/);
await save(page, 'login-en');
});