WTC-39: скрыть «Полегче/Посложнее» на пустом списке
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 4s
deploy / deploy (pull_request) Successful in 13s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Peppa 2026-11-16 06:44:23 +05:00
parent 7ce33d7393
commit b79a546b2a
3 changed files with 21 additions and 0 deletions

View File

@ -24,6 +24,7 @@
- WTC-32: примеры на экране — постоянный набор exampleStates() (4 блюда, флаг added); добавленный — disabled «— добавлено», все добавлены — текст examplesAllAdded.
- WTC-33: подпись без рецепта — i18n noRecipe «Рецепта для этого блюда пока нет», в списке span.no-recipe, в выдаче #noRecipeToday.
- WTC-35: «Полегче/Посложнее» всегда видны, disabled без блюда; подсказка #tuneInfo (tuneHint+tuneOff), результат #tuneResult (tuneDone «Теперь: …»), ошибка — #tuneError.
- WTC-39: на пустом списке (n===0) блоки #tune и #tuneInfo скрыты в render(); при непустом списке без выбранного блюда «Полегче/Посложнее» остаются disabled с пояснением. Остальные критерии были готовы раньше.
## Соглашения
- Цвета кнопки: доступная #b4500c, недоступная #e8dccb/#5c4a35 (контраст ≥4.5:1, проверяется тестом); opacity для disabled не используем.

View File

@ -44,6 +44,7 @@ function render() {
$("level").textContent = lvl === null ? "" : t.difficulty.replace("{level}", t[LEVEL_KEYS[lvl]]);
$("easier").disabled = $("harder").disabled = !show;
if (!show) $("tuneResult").hidden = true;
$("tune").hidden = $("tuneInfo").hidden = n === 0;
$("tuneInfo").textContent = show ? t.tuneHint : t.tuneHint + " " + t.tuneOff;
$("easier").textContent = t.easier;
$("harder").textContent = t.harder;

19
test/empty-screen.test.js Normal file
View File

@ -0,0 +1,19 @@
import test from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
const read = (f) => readFileSync(new URL(`../src/${f}`, import.meta.url), "utf8");
test("Сценарий: на пустом списке «Полегче» и «Посложнее» скрыты", () => {
assert.match(read("app.js"), /\$\("tune"\)\.hidden = \$\("tuneInfo"\)\.hidden = n === 0/);
});
test("Сценарий: «Назад» только внутри карточки рецепта", () => {
const h = read("index.html");
const recipe = h.slice(h.indexOf('<article id="recipe"'));
const home = h.slice(0, h.indexOf('<article id="recipe"'));
assert.match(recipe, /id="back"/);
assert.doesNotMatch(home, /id="back"/);
});
test("Сценарий: [hidden] у блока кнопок действует", () => {
assert.match(read("style.css"), /\[hidden\]\s*\{\s*display:\s*none/);
});