import test from "node:test"; import assert from "node:assert/strict"; import { CHANNELS, listChannels, AUTO, PRIORITIES } from "../src/channels.js"; import { TEXTS, LANGS } from "../src/i18n.js"; const IDS = ["linkedin", "instagram", "facebook", "telegram", "site", "youtube", "tiktok", "threadsx", "email", "media", "whatsapp", "search"]; test("Сценарий: в таблице все 12 каналов из ТЗ", () => { assert.deepEqual(CHANNELS.map((c) => c.id), IDS); }); test("Сценарий: неизвестное не выдумано — пустые поля null, доступ не подтверждён", () => { for (const c of CHANNELS) { for (const f of ["audience", "goal", "role", "metrics"]) assert.equal(c[f], null, `${c.id}.${f}`); assert.ok(c.priority === null || PRIORITIES.includes(c.priority)); if (!["linkedin", "site"].includes(c.id)) { assert.equal(c.access, "unconfirmed"); assert.equal(c.status, "unconfirmed"); } } assert.equal(CHANNELS.find((c) => c.id === "site").link, "https://growconsult.kz"); assert.equal(CHANNELS.filter((c) => c.link).length, 1); }); test("Сценарий: без автопубликации так и написано, фразы «публикую автоматически» нет, есть ручная задача", () => { assert.ok(listChannels().every((c) => AUTO.includes(c.auto) && (c.auto === "yes" || c.manualTask))); for (const l of LANGS) { for (const k of ["ui.ch.auto.no", "ui.ch.auto.pending", "ui.ch.fallback"]) assert.ok(TEXTS[l][k], `${l} ${k}`); assert.doesNotMatch(Object.entries(TEXTS[l]).filter(([k]) => k.startsWith("ui.ch.") && k !== "ui.ch.auto.yes").map(([, v]) => v).join(" "), /публикую автоматически|post automatically/i); } assert.match(TEXTS.ru["ui.ch.auto.no"], /ручную публикацию/); }); test("Сценарий: тексты есть на трёх языках для каждого канала и поля", () => { const keys = ["ui.ch.title", "ui.ch.clarify", ...IDS.flatMap((i) => [`ui.ch.name.${i}`, `ui.ch.limits.${i}`])]; for (const l of LANGS) for (const k of keys) assert.ok(TEXTS[l][k], `${l} ${k}`); });