dika/test/home-texts.test.js
Peppa eff969602d
All checks were successful
peppa/lint lint: success за 0с
peppa/test test: success за 0с
peppa/build build: success за 0с
ci / checks (pull_request) Successful in 10s
deploy / deploy (pull_request) Successful in 18s
DIK-23: тест и спека: главная без служебных фраз, всё подписано, один язык
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-18 17:13:22 +05:00

35 lines
1.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.

// DIK-23: главная без служебных фраз, всё подписано, тексты на одном языке.
import { test } from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
const html = readFileSync(new URL("../public/index.html", import.meta.url), "utf8");
const tr = (l) => JSON.parse(readFileSync(new URL(`../public/i18n/${l}.json`, import.meta.url), "utf8"));
test("сценарий «Нет служебных фраз»: на главной нет Esil и Almaty", () => {
for (const l of ["ru", "kk", "en"]) {
const t = tr(l);
for (const [k, v] of Object.entries(t)) {
if (typeof v === "string" && !k.startsWith("adm")) assert.doesNotMatch(v, /\b(esil|almaty)\b/i, `${l}.${k}`);
}
}
assert.doesNotMatch(html, /\b(esil|almaty)\b/i);
});
test("сценарий «Всё подписано»: у кнопок есть текст или подпись, у полей — label", () => {
for (const m of html.matchAll(/<button\b([^>]*)>([\s\S]*?)<\/button>/g)) {
assert.match(m[1] + m[2], /data-i=|data-al=|aria-label=|>[^<\s][^<]*</, m[0]);
}
for (const id of ["addr", "maxKm", "maxPrice"]) assert.match(html, new RegExp(`<label for="${id}"`));
});
test("сценарий «Один язык»: по умолчанию русский, RU/KK/EN есть, ключи совпадают", () => {
assert.match(html, /<html lang="ru"/);
for (const l of ["ru", "kk", "en"]) assert.match(html, new RegExp(`data-l="${l}"`));
const keys = Object.keys(tr("ru")).sort();
assert.deepEqual(Object.keys(tr("kk")).sort(), keys);
assert.deepEqual(Object.keys(tr("en")).sort(), keys);
const ru = /[А-Яа-я]/;
for (const k of ["subtitle", "useLocation", "noDescription"]) assert.doesNotMatch(tr("en")[k], ru, k);
});