diff --git a/locales/en.json b/locales/en.json index 9692e68..f0e7aba 100644 --- a/locales/en.json +++ b/locales/en.json @@ -907,7 +907,7 @@ "botp.test.never": "Access has not been checked yet.", "botp.test.check": "Check access now", "botp.test.h.log": "Test publication log (Almaty time)", - "botp.test.empty": "Empty so far.", + "botp.test.empty": "No journal entries yet.", "botp.test.mark": "test", "botp.test.k.armed": "scheduled start", "botp.test.k.blocked": "stopped", @@ -1003,5 +1003,12 @@ "botp.tg.check.ok": "The approval word matches. Send it to the bot.", "botp.tg.check.none": "The approval word is not set yet. Set it in the field above.", "botp.test.h.launch": "Scheduled launch time (Almaty time)", - "botp.test.launch.go": "Open “Strategy and rules”" + "botp.test.launch.go": "Open “Strategy and rules”", + "botp.test.card.notApproved": "No card yet: the agent will send it after Tatiana approves the strategy.", + "botp.test.card.later": "will appear in the card", + "botp.test.card.noChannel": "Channel: the private test channel is not confirmed yet", + "botp.test.card.timeLater": "Publication time: will appear in the card", + "botp.test.card.offWhy": "The buttons become available when the agent sends a card. You can decide here or in the bot.", + "botp.test.logNone": "Nothing sent: a post goes out only after «Approve», and nothing is approved yet.", + "botp.test.logSent": "Last sent: message No. {messageId}, {time} Almaty time. Sent in total: {n}." } diff --git a/locales/kk.json b/locales/kk.json index fddfb16..928ff4d 100644 --- a/locales/kk.json +++ b/locales/kk.json @@ -907,7 +907,7 @@ "botp.test.never": "Қолжетімділік әлі тексерілмеген.", "botp.test.check": "Қолжетімділікті қазір тексеру", "botp.test.h.log": "Тексеру жарияланымдарының журналы (Алматы уақыты)", - "botp.test.empty": "Әзірге бос.", + "botp.test.empty": "Журналда әзірге жазба жоқ.", "botp.test.mark": "тест", "botp.test.k.armed": "кесте бойынша басталды", "botp.test.k.blocked": "тоқтатылды", @@ -1003,5 +1003,12 @@ "botp.tg.check.ok": "Мақұлдау сөзі сәйкес келеді. Оны ботқа жазыңыз.", "botp.tg.check.none": "Мақұлдау сөзі әлі берілмеген. Оны жоғарыдағы өріске беріңіз.", "botp.test.h.launch": "Кесте бойынша іске қосу уақыты (Алматы уақыты)", - "botp.test.launch.go": "«Стратегия және ережелер» бетін ашу" + "botp.test.launch.go": "«Стратегия және ережелер» бетін ашу", + "botp.test.card.notApproved": "Әзірге карточка жоқ: Татьяна стратегияны бекіткеннен кейін агент оны жібереді.", + "botp.test.card.later": "карточкада пайда болады", + "botp.test.card.noChannel": "Арна: тексеруге арналған жабық арна әлі расталмаған", + "botp.test.card.timeLater": "Жариялау уақыты: карточкада пайда болады", + "botp.test.card.offWhy": "Агент карточканы жібергенде батырмалар қолжетімді болады. Шешімді осында немесе ботта қабылдауға болады.", + "botp.test.logNone": "Ештеңе жіберілмеді: жарияланым тек «Мақұлдау» басылғаннан кейін кетеді, ал мақұлданғандар әзірге жоқ.", + "botp.test.logSent": "Соңғы жіберілгені: №{messageId} хабарлама, Алматы уақытымен {time}. Барлығы жіберілді: {n}." } diff --git a/locales/ru.json b/locales/ru.json index a7c24de..d6bec0d 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -907,7 +907,7 @@ "botp.test.never": "Проверки доступа ещё не было.", "botp.test.check": "Проверить доступ сейчас", "botp.test.h.log": "Журнал проверочных публикаций (время по Алматы)", - "botp.test.empty": "Пока пусто.", + "botp.test.empty": "Записей в журнале пока нет.", "botp.test.mark": "тест", "botp.test.k.armed": "запуск по расписанию", "botp.test.k.blocked": "остановлено", @@ -1003,5 +1003,12 @@ "botp.tg.check.ok": "Слово для одобрения подходит. Напишите его боту.", "botp.tg.check.none": "Слово для одобрения ещё не задано. Задайте его в поле выше.", "botp.test.h.launch": "Время запуска по расписанию (по Алматы)", - "botp.test.launch.go": "Открыть «Стратегия и правила»" + "botp.test.launch.go": "Открыть «Стратегия и правила»", + "botp.test.card.notApproved": "Карточки пока нет: агент пришлёт её после того, как Татьяна утвердит стратегию.", + "botp.test.card.later": "появится в карточке", + "botp.test.card.noChannel": "Канал: закрытый канал для проверки ещё не подтверждён", + "botp.test.card.timeLater": "Время публикации: появится в карточке", + "botp.test.card.offWhy": "Кнопки станут доступны, когда агент пришлёт карточку. Решение можно будет принять здесь или в боте.", + "botp.test.logNone": "Ничего не отправлено: публикация уходит только после «Одобрить», а одобренных пока нет.", + "botp.test.logSent": "Последняя отправка: сообщение №{messageId}, {time} по Алматы. Всего отправлено: {n}." } diff --git a/openspec/changes/brm-156-approval-path-visible/design.md b/openspec/changes/brm-156-approval-path-visible/design.md new file mode 100644 index 0000000..e23e90b --- /dev/null +++ b/openspec/changes/brm-156-approval-path-visible/design.md @@ -0,0 +1,14 @@ +# Design + +- Только представление: `testBox`/`cardBox` в `src/bot-page.js`; данные — из `testRun.view()` + (cards, log, sentCount, channel, next, approved). Новых данных и маршрутов нет. +- Пустая карточка — отдельная функция `emptyCard`: тот же `id="trcard"` и класс `card`, что у + настоящей, чтобы приёмка находила карточку по одному месту. Кнопки — ``).join(" "); + const channel = tr.channel ? B("card.channel", { title: tr.channel.title }) : L("card.noChannel"); + const time = approved && tr.next ? B("card.time", { time: almatyTime(tr.next.at) }) : L("card.timeLater"); + return `

${L("mark")} ${approved ? L("card.none") : L("card.notApproved")}

+

${B("card.text")}: ${L("card.later")}

+

${B("card.assets")}: ${L("card.later")}

+

${channel}

+

${time}

+

${L("card.nothing.closed")}

+

${btns}

${L("card.offWhy")}

`; +} + // BRM-143: проверочная публикация — запуск, канал, что мешает (причина, кто снимает, что сделать), журнал с меткой «тест». function testBox(lang, tr, q, view = {}) { if (!tr) return ""; @@ -125,13 +142,17 @@ function testBox(lang, tr, q, view = {}) { if (e.link) s += ` ${L("open")}`; return s; }; + // BRM-156: итог журнала — «Ничего не отправлено» или последняя отправка: номер, время, ссылка. + const lastSent = tr.log.find((e) => e.kind === "sent"); + const logSum = lastSent + ? `

${L("mark")} ${L("logSent", { messageId: lastSent.messageId, time: almatyTime(lastSent.sentAt ?? lastSent.at), n: tr.sentCount ?? 1 })}${lastSent.link ? ` ${L("card.open")}` : ""}

` + : `

${L("mark")} ${L("logNone")}

`; const log = tr.log.length ? `` : `

${L("empty")}

`; const [last, ...older] = tr.cards ?? []; const msg = view.cardMsg ? `

${L("card.msg." + view.cardMsg)}

` : ""; - const cards = !approved && !tr.armedAt ? "" - : `

${L("h.card")}

${msg}${last ? cardBox(lang, last, { q, wordSet: view.wordSet, full: true }) + older.slice(0, OLD_CARDS).map((c) => cardBox(lang, c, { q, full: false })).join("") : `

${L("card.none")}

`}`; + const cards = `

${L("h.card")}

${msg}${last ? cardBox(lang, last, { q, wordSet: view.wordSet, full: true }) + older.slice(0, OLD_CARDS).map((c) => cardBox(lang, c, { q, full: false })).join("") : emptyCard(lang, tr, approved)}`; return `

${esc(t(lang, "botp.h.test"))}

${esc(t(lang, "botp.test.lead"))}

${L("h.launch")}

@@ -140,7 +161,7 @@ ${launch}${channel}${check}
${cards}

${L("h.log")}

-${log}`; +${logSum}${log}`; } // BRM-150: «Бот в Telegram» — бот найден (имя подтвердил Telegram), получает ли сообщения, привязка владельца. // Ключ бота здесь не бывает: в view только имя бота, флаги и имя привязанного владельца. diff --git a/test/brm147-test-path-screen.test.js b/test/brm147-test-path-screen.test.js index 823cb15..3a70c54 100644 --- a/test/brm147-test-path-screen.test.js +++ b/test/brm147-test-path-screen.test.js @@ -66,12 +66,13 @@ test("Сценарий: Стратегия утверждена — время assert.match(text(html), /Ближайший запуск: 22\.11\.2026 12:00 по Алматы/); }); -test("Сценарий: Стратегия не утверждена — блока карточки нет", async () => { +test("Сценарий: Стратегия не утверждена — карточка пустая (BRM-156)", async () => { const s = setup({ approve: false }); await s.ready(); const html = s.page(); assert.match(text(html), /Запуска по расписанию не будет, пока стратегия не утверждена/); - assert.ok(!html.includes('id="trcards"')); + assert.ok(html.includes('id="trcards"')); + assert.ok(!html.includes('id="trform"')); assert.ok(!html.includes('id="trnext"')); }); @@ -159,3 +160,55 @@ test("Сценарий: Одобрение со страницы, неверно assert.match(await decide("tanya-2026", "approve"), /card=closed/); } finally { app.close(); } }); + +// BRM-156: путь согласования виден всегда — пустая карточка и итог журнала (specs/test-path-screen). +const cardHtml = (html) => html.slice(html.indexOf('id="trcard"'), html.indexOf("", html.indexOf('id="trcard"'))); + +test("BRM-156 Сценарий: Стратегия не утверждена — карточка пустая", async () => { + const s = setup({ approve: false }); + const html = s.page(); + const box = cardHtml(html); + for (const w of ["тест", "Карточки пока нет: агент пришлёт её после того, как Татьяна утвердит стратегию", "Текст:", "Материалы:", "Канал:", "Время публикации:", "Ничего не отправлено."]) assert.ok(text(box).includes(w), w); + for (const b of ["Одобрить", "Доработать", "Отклонить"]) assert.match(box, new RegExp(``)); + assert.match(box, /id="trcardwhy">Кнопки станут доступны, когда агент пришлёт карточку/); + assert.ok(!html.includes(" disabled>")); +}); + +test("BRM-156 Сценарий: Канал подтверждён, карточки ещё нет", async () => { + const s = setup(); + await s.ready(); + const box = text(cardHtml(s.page())); + assert.ok(box.includes("Канал: «Тест BRM» — закрытый канал для проверки")); + assert.ok(box.includes("Время публикации: 22.11.2026 12:00 по Алматы")); + assert.ok(box.includes("Карточки пока не было.")); +}); + +test("BRM-156 Сценарий: Одобрения нет — в журнале «Ничего не отправлено»", async () => { + const s = setup({ approve: false }); + let html = s.page(); + assert.match(text(html), /тест Ничего не отправлено: публикация уходит только после «Одобрить», а одобренных пока нет\./); + assert.ok(!text(html).includes("Пока пусто.")); + const s2 = setup(); + await s2.ready(); + await s2.tick(T0 + 60e3); + await s2.tick(NOON); + html = s2.page(); + assert.match(html, /id="trlogsum" class="st off">/); +}); + +test("BRM-156 Сценарий: После одобрения публикация ушла — журнал", async () => { + const s = setup(); + await s.ready(); + await s.tick(T0 + 60e3); + await s.press(s.btn("Одобрить")); + await s.tick(NOON); + const html = s.page(); + assert.match(html, /id="trlogsum" class="st ok">тест<\/b> Последняя отправка: сообщение №1, 22\.11\.2026 12:00 по Алматы\. Всего отправлено: 1\. ]*>Открыть сообщение<\/a>/); +}); + +test("BRM-156: тексты пустой карточки и журнала есть на всех языках", () => { + for (const lang of ["ru", "kk", "en"]) { + const html = botPage(lang, { sending: false, paused: false, missing: null, reports: { day: { last: null, next: null }, week: { last: null, next: null } }, errors: [], testRun: { log: [], cards: [], approved: false, sentCount: 0, why: String } }); + for (const k of ["botp.test.card.notApproved", "botp.test.logNone", "botp.test.card.offWhy"]) assert.ok(!html.includes(k), `${lang}: ${k}`); + } +});