DIK-16: пояснение на /base при пустом списке, тест стартовой базы

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Peppa 2026-11-16 14:06:57 +05:00
parent a88a022f08
commit 54169bec14
5 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1 @@
Пустой ответ /api/base показывает текст listPreparing (ru/kk/en уже есть). Данные не менялись: все даты проверки 16.11.2026.

View File

@ -0,0 +1,2 @@
# DIK-16: стартовая база на странице «Все заведения»
База (29 заведений, Есиль и Алматы) и страница /base уже есть. Добавляем: пояснение вместо пустой страницы, пока заведений нет, и тест на объём/дубли/даты.

View File

@ -0,0 +1,2 @@
- [x] Пояснение при пустом списке в public/base.js
- [x] Тест на ≥20 заведений, без дублей, с датой проверки

View File

@ -15,6 +15,7 @@ try {
const list = await r.json();
document.getElementById("count").textContent = fmt(t.baseCount, { n: list.length });
const body = document.getElementById("rows");
if (!list.length) { const e = document.getElementById("err"); e.textContent = t.listPreparing; e.hidden = false; }
for (const v of list) {
const promo = v.promo ? (t.promoTexts?.[v.promo.text] || v.promo.text) + (v.promo.until ? ` (${date(v.promo.until)})` : "") : t.noPromo;
const lunch = v.lunch ? fmt(t.baseLunch, v.lunch) : t.noLunch;

View File

@ -51,3 +51,14 @@ test("Сценарий: список районов показывает, ско
assert.ok(ds.every((d) => Number.isInteger(d.count)));
assert.ok(ds.some((d) => d.count > 0));
});
test("Сценарий: стартовая база — не меньше 20 заведений без дублей, у каждого дата проверки", async () => {
const s = http.createServer(createHandler()).listen(0);
const base = `http://127.0.0.1:${s.address().port}`;
const list = await (await fetch(base + "/api/base")).json();
s.close();
assert.ok(list.length >= 20);
assert.equal(new Set(list.map((v) => v.name + "|" + v.address)).size, list.length);
assert.ok(new Set(list.map((v) => v.district)).has("Есиль") && new Set(list.map((v) => v.district)).has("Алматы"));
for (const v of list) assert.match(v.checked, /^\d{4}-\d{2}-\d{2}$/);
});