// BRM-182: на «Бот и отчёты» видно, как проверено слово для одобрения — цепочка на отдельной копии. import test from "node:test"; import assert from "node:assert/strict"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import { runWordProof, PROOF_NEW, PROOF_OLD } from "../src/word-proof.js"; import { mockTelegramApi } from "../src/telegram.js"; import { createApp } from "../src/server.js"; import { t } from "../src/i18n.js"; import { webhookSecret, WEBHOOK_PATH } from "../src/bot-identity.js"; const STEPS = ["set", "replace", "checkSpaces", "checkCase", "checkOld", "stateBefore", "botOld", "botNew", "restart", "stranger", "stored"]; test("BRM-182 Сценарий: цепочка смены слова видна на странице", async () => { const dir = fs.mkdtempSync(path.join(os.tmpdir(), "brm182-")); const realOwner = path.join(dir, "owner.json"); // Версия для проверки, куда Telegram шлёт сообщения бота (как на настоящей версии для проверки). const TOKEN = "123456:MOCK_SECRET_TOKEN_VALUE", HOST = "brendmanager-staging.telecom.quest"; const telegram = mockTelegramApi({ token: TOKEN, webhook: { url: `https://${HOST}${WEBHOOK_PATH}` } }); const app = createApp({ file: path.join(dir, "plan.json"), telegram, ownerCode: undefined, webhookSecret: webhookSecret(TOKEN, {}), siteUrl: `https://${HOST}` }); await new Promise((r) => app.listen(0, r)); try { for (const lang of ["ru", "kk", "en"]) { const html = await fetch(`http://127.0.0.1:${app.address().port}/bot.html?lang=${lang}`).then((r) => r.text()); assert.ok(html.includes(t(lang, "botp.proof.h")), lang); assert.match(html, /id="wordproofsum" class="st ok"/, lang); for (const s of STEPS) assert.match(html, new RegExp(`