dika/test/client.test.js
Peppa 0e37368363
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 5s
deploy / deploy (pull_request) Successful in 14s
DIK-6: язык запоминается, районы и акции переведены на три языка
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 13:51:22 +05:00

42 lines
2.0 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.

import test from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
const app = fs.readFileSync("public/app.js", "utf8");
test("Сценарий: местоположение не отвечает — ожидание ограничено 10 секундами", () => {
assert.match(app, /timeout:\s*10000/);
});
test("Сценарий: рядом нет заведений — открывается выбор района и адреса", () => {
assert.match(app, /if \(far\) showManual\(\)/);
});
test("Тексты ожидания есть на трёх языках", () => {
for (const l of ["ru", "kk", "en"]) assert.ok(JSON.parse(fs.readFileSync(`public/i18n/${l}.json`, "utf8")).searching);
});
test("Сценарий: у каждого поля и кнопки без текста есть подпись на трёх языках", () => {
const html = fs.readFileSync("public/index.html", "utf8");
assert.doesNotMatch(html, /aria-label="Menu"/);
assert.match(html, /<label for="district"/);
assert.match(html, /<label for="addr"/);
assert.match(html, /id="burger" data-al="menuOpen"/);
for (const l of ["ru", "kk", "en"]) {
const d = JSON.parse(fs.readFileSync(`public/i18n/${l}.json`, "utf8"));
for (const k of ["menuOpen", "menuLabel", "districtLabel", "districtPlaceholder", "addressLabel"]) assert.ok(d[k], `${l}.${k}`);
}
});
test("Сценарий: выбранный язык запоминается и применяется при следующем открытии", () => {
assert.match(app, /localStorage\.setItem\("lang", l\)/);
assert.match(app, /LANGS\.includes\(saved\(\)\)/);
});
test("Сценарий: названия районов и акции переведены, смеси языков нет", () => {
for (const l of ["kk", "en"]) {
const d = JSON.parse(fs.readFileSync(`public/i18n/${l}.json`, "utf8"));
assert.ok(d.district_esil && d.district_almaty && Object.keys(d.promoTexts).length >= 3, l);
}
});