WTC-26: подсказка про «Рецепта нет» на пустом экране #26

Merged
peppa-bot merged 4 commits from task/wtc-26 into main 2026-11-16 06:29:18 +05:00
4 changed files with 16 additions and 2 deletions

View File

@ -16,6 +16,7 @@
- WTC-19: фраза про кнопку «Рецепт» — абзац #recipesHint (i18n listRecipes), видна только когда hasRecipe(dishes, findRecipe) из logic.js, т.е. в списке есть блюдо с кнопкой; на пустом экране её нет (требование WTC-14 снято).
- WTC-20: пока в списке нет блюда с кнопкой «Рецепт», виден блок #recipeExample (подсказка + кнопка #addExample «Добавить «…»», пример = recipeExample() в logic.js); иначе — фраза #recipesHint (WTC-19). Подпись #noRecipeHint под списком — при блюде без рецепта (hasNoRecipe).
- WTC-24: подсказка под кнопкой «Что приготовить?» — i18n pickHint (в app.js #hint: пусто→emptyHint, одно блюдо после выбора→oneHint, иначе pickHint); остальные критерии были готовы с WTC-5..8.
- WTC-26: #noRecipeHint виден на пустом экране (n===0) или при блюде без рецепта; вместе с #recipeExample объясняет оба случая. sed на macOS с | и & падает — правь через Edit.
## Соглашения
- Цвета кнопки: доступная #b4500c, недоступная #e8dccb/#5c4a35 (контраст ≥4.5:1, проверяется тестом); opacity для disabled не используем.

View File

@ -53,7 +53,7 @@ function render() {
$("addExample").textContent = example === null ? "" : t.addExample.replace("{name}", example);
$("addExample").dataset.name = example ?? "";
$("noRecipeHint").textContent = t.noRecipeHint;
$("noRecipeHint").hidden = !hasNoRecipe(state.dishes, findRecipe);
$("noRecipeHint").hidden = n !== 0 && !hasNoRecipe(state.dishes, findRecipe);
const ul = $("list");
ul.replaceChildren(...state.dishes.map((d) => {
const li = document.createElement("li");

View File

@ -0,0 +1,13 @@
import test from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { messages } from "../src/i18n.js";
// WTC-26: на пустом экране объяснено и про кнопку «Рецепт», и про «Рецепта нет»
test("Сценарий: Пустой экран объясняет оба случая", () => {
const app = readFileSync(new URL("../src/app.js", import.meta.url), "utf8");
assert.match(app, /\$\("noRecipeHint"\)\.hidden = n !== 0 && !hasNoRecipe\(/);
assert.match(messages.ru.recipeExampleHint, /кнопка «Рецепт»/);
assert.match(messages.ru.noRecipeHint, /«Рецепта нет»/);
for (const l of ["ru", "kk", "en"]) assert.ok(messages[l].noRecipeHint.length > 20, l);
});

View File

@ -53,7 +53,7 @@ test("Сценарий: Своё блюдо в списке", () => {
assert.equal(findRecipe("Мамин пирог"), null);
assert.match(messages.ru.noRecipeHint, /«Рецепта нет»/);
assert.ok(messages.ru.noRecipeHint.includes(messages.ru.noRecipe));
assert.match(read("app.js"), /\$\("noRecipeHint"\)\.hidden = !hasNoRecipe\(state\.dishes, findRecipe\)/);
assert.match(read("app.js"), /\$\("noRecipeHint"\)\.hidden = n !== 0 && !hasNoRecipe\(state\.dishes, findRecipe\)/);
const html = read("index.html");
assert.ok(html.indexOf('id="list"') < html.indexOf('id="noRecipeHint"'));
});