From 064b17a26efab5b6c566ea3a189deecf998cfc1c Mon Sep 17 00:00:00 2001 From: Peppa Date: Mon, 16 Nov 2026 06:32:11 +0500 Subject: [PATCH] =?UTF-8?q?WTC-29:=20=D0=BF=D0=BE=D0=B4=D1=81=D0=BA=D0=B0?= =?UTF-8?q?=D0=B7=D0=BA=D0=B0=20=D0=BF=D0=BE=D0=B4=20=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D0=B5=D0=BC=20=D0=BF=D1=80=D0=BE=20=D0=B1=D0=BB=D1=8E=D0=B4?= =?UTF-8?q?=D0=B0=20=D0=B8=D0=B7=20=D0=B1=D0=B0=D0=B7=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 --- src/app.js | 1 + src/i18n.js | 3 +++ src/index.html | 1 + test/suggest-hint.test.js | 21 +++++++++++++++++++++ 4 files changed, 26 insertions(+) create mode 100644 test/suggest-hint.test.js diff --git a/src/app.js b/src/app.js index 5d750fd..32f8d31 100644 --- a/src/app.js +++ b/src/app.js @@ -50,6 +50,7 @@ function render() { const examples = hasRecipe(state.dishes, findRecipe) ? [] : recipeExamples(state.dishes, catalog, findRecipe); $("recipeExample").hidden = examples.length === 0; $("recipeExampleHint").textContent = t.recipeExampleHint; + $("suggestHint").textContent = t.suggestHint; $("examplesNote").textContent = t.examplesNote; $("examples").replaceChildren(...examples.map((name) => { const b = document.createElement("button"); diff --git a/src/i18n.js b/src/i18n.js index 5cdbb84..ade4ef0 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -23,6 +23,7 @@ export const messages = { today: "Сегодня готовим:", recipe: "Рецепт", noRecipe: "Рецепта нет", + suggestHint: "Начните вводить — предложим блюда из базы казахской кухни.", fromCatalog: "Из базы", recipeLabel: "Рецепт блюда «{name}»", back: "Назад", @@ -61,6 +62,7 @@ export const messages = { today: "Бүгін дайындаймыз:", recipe: "Рецепт", noRecipe: "Рецепт жоқ", + suggestHint: "Жаза бастаңыз — қазақ тағамдары қорынан тағамдар ұсынамыз.", fromCatalog: "Қордан", recipeLabel: "«{name}» тағамының рецепті", back: "Артқа", @@ -99,6 +101,7 @@ export const messages = { today: "Today you cook:", recipe: "Recipe", noRecipe: "No recipe", + suggestHint: "Start typing — we will suggest dishes from the Kazakh cuisine base.", fromCatalog: "From the base", recipeLabel: "Recipe for “{name}”", back: "Back", diff --git a/src/index.html b/src/index.html index 2590db3..9c34c2c 100644 --- a/src/index.html +++ b/src/index.html @@ -17,6 +17,7 @@ +

diff --git a/test/suggest-hint.test.js b/test/suggest-hint.test.js new file mode 100644 index 0000000..4ded571 --- /dev/null +++ b/test/suggest-hint.test.js @@ -0,0 +1,21 @@ +import test from "node:test"; +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import { messages } from "../src/i18n.js"; +import { suggest, inCatalog } from "../src/logic.js"; +import { catalog } from "../src/catalog.js"; + +test("Сценарий: подсказка под полем на трёх языках", () => { + for (const l of ["ru", "kk", "en"]) assert.ok(messages[l].suggestHint); + assert.match(messages.ru.suggestHint, /Начните вводить/); + assert.match(readFileSync("src/index.html", "utf8"), /id="suggestHint"/); + assert.match(readFileSync("src/app.js", "utf8"), /suggestHint/); +}); +test("Сценарий: при вводе названия из базы виден список", () => { + const r = suggest("беш", catalog, []); + assert.ok(r.length > 0); +}); +test("Сценарий: пометка только у блюда из базы", () => { + assert.equal(inCatalog("бешбармак", catalog), true); + assert.equal(inCatalog("Мамин пирог", catalog), false); +});