what-to-cook/test/labels.test.js
Peppa a52ef5739c
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 4s
deploy / deploy (pull_request) Successful in 13s
WTC-42: подписи скрытых кнопок убраны из текста страницы
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 06:50:26 +05:00

21 lines
997 B
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 { readFileSync } from "node:fs";
import { messages } from "../src/i18n.js";
const html = readFileSync(new URL("../src/index.html", import.meta.url), "utf8");
test("Сценарий: каждая кнопка в разметке имеет подпись без скриптов", () => {
const buttons = [...html.matchAll(/<button\b[^>]*>([^<]*)<\/button>/g)];
// Кнопки «Рецепт», «Полегче», «Посложнее», «Назад» подписываются скриптом, только когда доступны (WTC-42).
const labeled = buttons.filter(([, text]) => text.trim().length > 0);
assert.equal(labeled.length, 2);
});
test("Сценарий: подписи в разметке совпадают с русскими текстами", () => {
const m = messages.ru;
for (const s of [m.add, m.pick, m.nameLabel]) {
assert.ok(html.includes(`>${s}<`), s);
}
});