From dab846deba93b6e5b11f191bc44aab8fb041c6af Mon Sep 17 00:00:00 2001 From: peppa-bot Date: Tue, 24 Nov 2026 09:43:47 +0000 Subject: [PATCH] =?UTF-8?q?DIK-74:=20=D0=BD=D0=BE=D0=B2=D1=8B=D0=B9=20?= =?UTF-8?q?=D0=B2=D0=B8=D0=B4=20=D0=B3=D0=BB=D0=B0=D0=B2=D0=BD=D0=BE=D0=B9?= =?UTF-8?q?=20=D0=B8=20=D0=BA=D0=B0=D1=80=D1=82=D0=BE=D1=87=D0=B5=D0=BA,?= =?UTF-8?q?=20=D1=82=D1=80=D0=B8=20=D0=B2=D0=B0=D1=80=D0=B8=D0=B0=D0=BD?= =?UTF-8?q?=D1=82=D0=B0=20=D0=BE=D1=84=D0=BE=D1=80=D0=BC=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20(=3Flook=3Da|b|c)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- public/app.js | 3 +- public/index.html | 137 +++++++++++++++++++++++++++++++--------------- test/look.test.js | 49 +++++++++++++++++ 3 files changed, 144 insertions(+), 45 deletions(-) create mode 100644 test/look.test.js diff --git a/public/app.js b/public/app.js index 57ec1f3..d5060f6 100644 --- a/public/app.js +++ b/public/app.js @@ -64,6 +64,7 @@ async function show() { if (list.some((v) => v.walk && v.walk.approx)) { const n = document.createElement("div"); n.className = "msg note"; n.textContent = t.walkApproxNote; out.append(n); } + const grid = document.createElement("div"); grid.className = "list"; out.append(grid); // карточки сеткой с отступами (DIK-74) for (const v of list) { const c = document.createElement("div"); c.className = "card"; const body = document.createElement("div"); body.className = "body"; @@ -84,7 +85,7 @@ async function show() { if (v.promo) body.append(tag(fmt(v.promo.until ? t.promo : t.promoOpen, { text: ptext(v.promo.text), until: v.promo.until && ruDate(v.promo.until) }), "promo")); else body.append(meta(v.promoState === "ended" ? t.promoEnded : t.promoNone, "offer-none")); if ((v.lunch || v.promo) && v.checked) body.append(meta(fmt(t.checkedOn, { date: ruDate(v.checked) }))); - out.append(c); + grid.append(c); } } // Фото или заглушка: пустого места на карточке не бывает, в том числе если картинка не загрузилась. diff --git a/public/index.html b/public/index.html index 53f8429..ec55afa 100644 --- a/public/index.html +++ b/public/index.html @@ -1,53 +1,100 @@ - - + + Обед рядом +

@@ -60,15 +107,16 @@ section{display:none}section.on{display:block}
-

+

-

+

- - +
+
+
@@ -77,6 +125,7 @@ section{display:none}section.on{display:block}
+
diff --git a/test/look.test.js b/test/look.test.js new file mode 100644 index 0000000..55cc5a8 --- /dev/null +++ b/test/look.test.js @@ -0,0 +1,49 @@ +// Новый вид главной и карточек (DIK-74): сценарии openspec/specs/home-look +import test from "node:test"; +import assert from "node:assert/strict"; +import fs from "node:fs"; + +const html = fs.readFileSync("public/index.html", "utf8"); +const app = fs.readFileSync("public/app.js", "utf8"); +const css = html.slice(html.indexOf("")); + +test("Сценарий: Открыт второй вариант — три набора оформления по ?look=", () => { + assert.match(html, //); + for (const l of ["b", "c"]) assert.match(css, new RegExp(`html\\[data-look="${l}"\\]\\{`)); + assert.match(html, /\/\^\[abc\]\$\/\.test\(l\|\|""\)\)document\.documentElement\.dataset\.look=l/); +}); + +test("Сценарий: Неизвестный вариант — остаётся вариант по умолчанию", () => { + const set = (search) => { const d = { dataset: { look: "a" } }; const l = new URLSearchParams(search).get("look"); if (/^[abc]$/.test(l || "")) d.dataset.look = l; return d.dataset.look; }; + assert.equal(set("?look=z"), "a"); assert.equal(set("?look=b"), "b"); assert.equal(set(""), "a"); +}); + +test("Сценарий: Главная на телефоне — крупный заголовок, одна главная кнопка, адрес и фильтры", () => { + assert.match(html, /

/); + assert.equal([...html.matchAll(/class="btn"/g)].length, 1, "одна залитая кнопка"); + assert.match(html, /