Merge pull request 'WTC-33: объяснить, почему у блюда нет кнопки «Рецепт»' (#33) from task/wtc-33 into main
This commit is contained in:
commit
29259862dd
@ -22,6 +22,7 @@
|
||||
- WTC-30: подсказка у кнопки — постоянный абзац #pickInfo (i18n pickHint, всегда виден); #hint теперь только emptyHint/oneHint и пуст в остальных случаях.
|
||||
- WTC-31: подписи кнопок и поля прописаны в index.html (ru по умолчанию), app.js их перезаписывает; test/labels.test.js проверяет, что пустых кнопок в разметке нет.
|
||||
- WTC-32: примеры на экране — постоянный набор exampleStates() (4 блюда, флаг added); добавленный — disabled «— добавлено», все добавлены — текст examplesAllAdded.
|
||||
- WTC-33: подпись без рецепта — i18n noRecipe «Рецепта для этого блюда пока нет», в списке span.no-recipe, в выдаче #noRecipeToday.
|
||||
|
||||
## Соглашения
|
||||
- Цвета кнопки: доступная #b4500c, недоступная #e8dccb/#5c4a35 (контраст ≥4.5:1, проверяется тестом); opacity для disabled не используем.
|
||||
|
||||
1
openspec/changes/wtc-33-explain-no-recipe/design.md
Normal file
1
openspec/changes/wtc-33-explain-no-recipe/design.md
Normal file
@ -0,0 +1 @@
|
||||
Текст noRecipe в i18n заменён на полную фразу; в результате выбора добавлен абзац #noRecipeToday вместо кнопки «Рецепт».
|
||||
4
openspec/changes/wtc-33-explain-no-recipe/proposal.md
Normal file
4
openspec/changes/wtc-33-explain-no-recipe/proposal.md
Normal file
@ -0,0 +1,4 @@
|
||||
## Why
|
||||
Рядом со своим блюдом нет «Рецепта», и непонятно почему.
|
||||
## What Changes
|
||||
Подпись «Рецепта для этого блюда пока нет» в списке и в результате выбора.
|
||||
@ -0,0 +1,9 @@
|
||||
## ADDED Requirements
|
||||
### Requirement: Пояснение, почему нет рецепта
|
||||
Для блюда без рецепта система SHALL показывать подпись «Рецепта для этого блюда пока нет» вместо кнопки «Рецепт».
|
||||
|
||||
#### Scenario: Блюдо без рецепта выпало в выборе
|
||||
- **GIVEN** в списке только своё блюдо «мантово»
|
||||
- **WHEN** пользователь нажимает «Что приготовить?»
|
||||
- **THEN** кнопки «Рецепт» нет
|
||||
- **AND** видна подпись «Рецепта для этого блюда пока нет»
|
||||
2
openspec/changes/wtc-33-explain-no-recipe/tasks.md
Normal file
2
openspec/changes/wtc-33-explain-no-recipe/tasks.md
Normal file
@ -0,0 +1,2 @@
|
||||
- [x] Подпись в списке и в выдаче (i18n, app.js, index.html)
|
||||
- [x] Тест test/no-recipe-today.test.js
|
||||
@ -35,6 +35,8 @@ function render() {
|
||||
$("dish").textContent = state.last ?? "";
|
||||
|
||||
$("recipeToday").hidden = !(show && findRecipe(state.last));
|
||||
$("noRecipeToday").hidden = !(show && !findRecipe(state.last));
|
||||
$("noRecipeToday").textContent = t.noRecipe;
|
||||
$("recipeToday").textContent = t.recipe;
|
||||
$("recipeToday").setAttribute("aria-label", show ? t.recipeLabel.replace("{name}", state.last) : "");
|
||||
const lvl = state.last ? difficultyOf(state.last) : null;
|
||||
|
||||
12
src/i18n.js
12
src/i18n.js
@ -19,12 +19,12 @@ export const messages = {
|
||||
exampleAdded: "«{name}» — добавлено",
|
||||
examplesAllAdded: "Все примеры добавлены. Впишите своё блюдо в поле выше.",
|
||||
examplesNote: "Это только примеры из нашей базы — можно вписать и своё блюдо.",
|
||||
noRecipeHint: "Пометка «Рецепта нет» стоит у блюд, которых нет в нашей базе. Рецепты есть только у блюд из базы.",
|
||||
noRecipeHint: "Подпись «Рецепта для этого блюда пока нет» стоит у блюд, которых нет в нашей базе. Рецепты есть только у блюд из базы.",
|
||||
pick: "Что приготовить?",
|
||||
yourDishes: "Ваши блюда",
|
||||
today: "Сегодня готовим:",
|
||||
recipe: "Рецепт",
|
||||
noRecipe: "Рецепта нет",
|
||||
noRecipe: "Рецепта для этого блюда пока нет",
|
||||
suggestHint: "Начните вводить — предложим блюда из базы казахской кухни.",
|
||||
fromCatalog: "Из базы",
|
||||
recipeLabel: "Рецепт блюда «{name}»",
|
||||
@ -60,12 +60,12 @@ export const messages = {
|
||||
exampleAdded: "«{name}» — қосылды",
|
||||
examplesAllAdded: "Барлық мысал қосылды. Өз тағамыңызды жоғарыдағы жолға жазыңыз.",
|
||||
examplesNote: "Бұл біздің қордағы мысалдар ғана — өз тағамыңызды да жаза аласыз.",
|
||||
noRecipeHint: "«Рецепт жоқ» белгісі біздің қорда жоқ тағамдарда тұрады. Рецепт тек қордағы тағамдарда бар.",
|
||||
noRecipeHint: "«Бұл тағамның рецепті әзірге жоқ» жазуы біздің қорда жоқ тағамдарда тұрады. Рецепт тек қордағы тағамдарда бар.",
|
||||
pick: "Не дайындаймыз?",
|
||||
yourDishes: "Сіздің тағамдарыңыз",
|
||||
today: "Бүгін дайындаймыз:",
|
||||
recipe: "Рецепт",
|
||||
noRecipe: "Рецепт жоқ",
|
||||
noRecipe: "Бұл тағамның рецепті әзірге жоқ",
|
||||
suggestHint: "Жаза бастаңыз — қазақ тағамдары қорынан тағамдар ұсынамыз.",
|
||||
fromCatalog: "Қордан",
|
||||
recipeLabel: "«{name}» тағамының рецепті",
|
||||
@ -101,12 +101,12 @@ export const messages = {
|
||||
exampleAdded: "“{name}” — added",
|
||||
examplesAllAdded: "All examples are added. Type your own dish in the field above.",
|
||||
examplesNote: "These are just examples from our collection — you can type your own dish too.",
|
||||
noRecipeHint: "“No recipe” marks dishes that are not in our collection. Only dishes from the collection have a recipe.",
|
||||
noRecipeHint: "“No recipe for this dish yet” marks dishes that are not in our collection. Only dishes from the collection have a recipe.",
|
||||
pick: "What to cook?",
|
||||
yourDishes: "Your dishes",
|
||||
today: "Today you cook:",
|
||||
recipe: "Recipe",
|
||||
noRecipe: "No recipe",
|
||||
noRecipe: "No recipe for this dish yet",
|
||||
suggestHint: "Start typing — we will suggest dishes from the Kazakh cuisine base.",
|
||||
fromCatalog: "From the base",
|
||||
recipeLabel: "Recipe for “{name}”",
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
<p id="today" class="today" hidden></p>
|
||||
<p id="dish" class="dish" hidden></p>
|
||||
<button id="recipeToday" type="button" class="recipe-btn" hidden>Рецепт</button>
|
||||
<p id="noRecipeToday" class="no-recipe" hidden></p>
|
||||
<p id="level" class="level" hidden></p>
|
||||
<div id="tune" class="tune" hidden>
|
||||
<button id="easier" type="button">Полегче</button>
|
||||
|
||||
@ -8,6 +8,6 @@ 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, /«Рецепта нет»/);
|
||||
assert.match(messages.ru.noRecipeHint, /«Рецепта для этого блюда пока нет»/);
|
||||
for (const l of ["ru", "kk", "en"]) assert.ok(messages[l].noRecipeHint.length > 20, l);
|
||||
});
|
||||
|
||||
13
test/no-recipe-today.test.js
Normal file
13
test/no-recipe-today.test.js
Normal 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";
|
||||
const read = (f) => readFileSync(new URL("../src/" + f, import.meta.url), "utf8");
|
||||
// WTC-33: подпись «Рецепта для этого блюда пока нет» в списке и в выдаче
|
||||
test("подпись без рецепта есть в выдаче и в списке", () => {
|
||||
assert.equal(messages.ru.noRecipe, "Рецепта для этого блюда пока нет");
|
||||
for (const l of ["ru", "kk", "en"]) assert.ok(messages[l].noRecipe, l);
|
||||
assert.match(read("index.html"), /id="noRecipeToday"/);
|
||||
assert.match(read("app.js"), /\$\("noRecipeToday"\)\.hidden = !\(show && !findRecipe\(state\.last\)\)/);
|
||||
assert.match(read("app.js"), /t\.noRecipe/);
|
||||
});
|
||||
@ -51,7 +51,7 @@ test("Граница: пример не повторяет блюдо из сп
|
||||
test("Сценарий: Своё блюдо в списке", () => {
|
||||
assert.equal(hasNoRecipe(["Бешбармак", "Мамин пирог"], findRecipe), true);
|
||||
assert.equal(findRecipe("Мамин пирог"), null);
|
||||
assert.match(messages.ru.noRecipeHint, /«Рецепта нет»/);
|
||||
assert.match(messages.ru.noRecipeHint, /«Рецепта для этого блюда пока нет»/);
|
||||
assert.ok(messages.ru.noRecipeHint.includes(messages.ru.noRecipe));
|
||||
assert.match(read("app.js"), /\$\("noRecipeHint"\)\.hidden = n !== 0 && !hasNoRecipe\(state\.dishes, findRecipe\)/);
|
||||
const html = read("index.html");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user