peppa/packages/testkit/test/connect-help.test.ts
peppa-bot f3d10a4c25 PEP-243: платформа называется FORGE — название во всех текстах для людей и подсказках агентам, адрес forge.telecom.quest
«Peppa FACTORY» → «FORGE» в экранах, сообщениях, словарях en/kk, шаблоне и тестах; «Пеппа» → «FORGE» в подсказках
агентам и правилах; логотип, значок, версия кэша service worker; в словаре старые названия — в «Нельзя».
Внутренние имена (CLI peppa, PEPPA_*, MCP-сервер peppa, ключи PEP-N) не меняются. Второй адрес — в mac-route.sh.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 11:18:49 +05:00

61 lines
3.5 KiB
TypeScript

// PEP-135: the guide «FORGE в вашем Claude или ChatGPT» — three languages, glossary words only.
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { describe, test } from "node:test";
import { CONNECT_HELP, CONNECT_LANGS, type ConnectHelpText } from "@peppa/core";
const strings = (t: ConnectHelpText) => [
t.title, t.lead, t.addressTitle, t.addressNote, t.copy, t.copied, t.askTitle, t.askLead, ...t.asks, t.troubleTitle,
...t.troubles.flatMap((x) => [x.q, x.a]), t.offTitle, t.off, t.offLink, t.other, t.linkFromHelp, t.linkLabel, t.back,
...t.apps.flatMap((a) => [a.title, a.need, ...a.steps]),
];
/** «Нельзя» column of docs/glossary.md. */
function forbidden(): string[] {
const rows = readFileSync(new URL("../../../docs/glossary.md", import.meta.url), "utf8")
.split("\n")
.filter((l) => l.startsWith("|") && !l.startsWith("|---") && !l.startsWith("| Понятие"));
return rows.flatMap((r) => r.split("|")[3]!.split(",").map((w) => w.trim()).filter(Boolean));
}
describe("PEP-135: инструкция подключения к своему чату", () => {
test("Продакт открывает инструкцию: шаги для Claude и ChatGPT, что написать, как отключить", () => {
const t = CONNECT_HELP.ru;
assert.deepEqual(t.apps.map((a) => a.id), ["claude", "chatgpt"]);
for (const a of t.apps) {
assert.ok(a.steps.length >= 5, a.id);
assert.match(a.steps.join(" "), /«Разрешить»/, `${a.id}: the consent button is named`);
}
assert.ok(t.asks.length >= 4);
assert.match(t.off, /«Подключённые приложения»/);
assert.match(t.off, /«Отозвать»/);
});
test("тексты есть на русском, казахском и английском, одной формы и без пустых строк", () => {
assert.deepEqual([...CONNECT_LANGS], ["ru", "kk", "en"]);
for (const lang of CONNECT_LANGS) {
const t = CONNECT_HELP[lang];
assert.deepEqual(t.apps.map((a) => a.id), ["claude", "chatgpt"], lang);
t.apps.forEach((a, i) => assert.equal(a.steps.length, CONNECT_HELP.ru.apps[i]!.steps.length, `${lang}: steps of ${a.id}`));
assert.equal(t.asks.length, CONNECT_HELP.ru.asks.length, lang);
assert.equal(t.troubles.length, CONNECT_HELP.ru.troubles.length, lang);
for (const s of strings(t)) assert.ok(s.trim().length > 0, lang);
assert.ok(strings(t).every((s) => !/Пеппа|Peppa/.test(s)), `${lang}: the product name is «FORGE»`);
}
assert.notDeepEqual(strings(CONNECT_HELP.kk), strings(CONNECT_HELP.ru));
assert.notDeepEqual(strings(CONNECT_HELP.en), strings(CONNECT_HELP.ru));
});
test("Слова из словаря: в русском тексте нет слов из колонки «Нельзя»", () => {
const words = forbidden();
assert.ok(words.includes("стори") && words.includes("токен"), "the glossary is parsed");
// Allowed: the product name, and «OAuth» as the literal name of a ChatGPT menu item.
const text = strings(CONNECT_HELP.ru).join("\n").replaceAll("FORGE", "").replaceAll("оставьте «OAuth»", "");
for (const w of words) {
const esc = w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const re = /^[\p{L}\p{N} ]+$/u.test(w) ? new RegExp(`(?<![\\p{L}\\p{N}])${esc}(?![\\p{L}\\p{N}])`, "iu") : new RegExp(esc, "u");
assert.doesNotMatch(text, re, `«${w}» is in the «Нельзя» column of docs/glossary.md`);
}
});
});