// 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(`(?