brendmanager/test/brm139-home-plain.test.js

53 lines
3.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import test from "node:test";
import assert from "node:assert/strict";
import { homePage, deployBox, DEPLOY_NOTES } from "../src/site.js";
import { botPage } from "../src/bot-page.js";
const ok = { last: { status: "ok", at: "2026-11-16T09:05:00Z", atText: "16.11.2026 14:05" }, shown: null };
const text = (h) => h.replace(/<script[\s\S]*?<\/script>/g, " ").replace(/<style[\s\S]*?<\/style>/g, " ").replace(/<[^>]+>/g, " ");
test("BRM-139 Сценарий: Успешное обновление — каждое изменение отдельным пунктом, без номеров задач и «выкладки»", () => {
for (const lang of ["ru", "kk", "en"]) {
const box = deployBox(lang, ok);
assert.equal((box.match(/<li>/g) || []).length, DEPLOY_NOTES.length, lang);
assert.doesNotMatch(text(box), /BRM-?\d+|\(\s*\d+\s*\)/, lang);
}
const ru = deployBox("ru", ok);
assert.match(ru, /Обновлено: 16\.11\.2026 14:05 по Алматы/);
assert.match(ru, /Последнее обновление прошло успешно\./);
assert.doesNotMatch(ru, /выкладк|появятся/i);
assert.match(deployBox("ru", { last: { status: "failed", atText: "16.11.2026 15:00" }, shown: null }), /Последнее обновление не удалось\./);
});
test("BRM-139 Сценарий: Пункт про итог по регионам понятен без пояснений", () => {
const a = homePage("ru", undefined, { running: { atText: "17.11.2026 06:00" } });
assert.match(a, /<li>В итоге по регионам на «Рынке» теперь написано, сколько конкурентов найдено и сколько было запланировано\.<\/li>/);
assert.doesNotMatch(a, /8 из 8/);
});
test("BRM-139 Сценарий: Те же текст и время в «Боте и отчётах»", () => {
assert.ok(botPage("ru", { sending: true, paused: false, connected: true, reports: { day: { last: null, next: null }, week: { last: null, next: null } }, errors: [] }, "", ok).includes(deployBox("ru", ok)));
});
test("BRM-139 Сценарий: Не указан профиль LinkedIn — без «ключ доступа»", () => {
const h = text(homePage("ru", undefined, ok, [], { linkedin: "author" }));
assert.match(h, /подключение к LinkedIn есть, но не указан профиль/);
assert.doesNotMatch(h, /ключ доступа/i);
});
for (const [name, missing] of [["Telegram", { telegram: "chat" }], ["LinkedIn", { linkedin: "author" }]]) {
test(`BRM-139 Сценарий: Пояснение у «версии для проверки» — ${name}`, () => {
const h = text(homePage("ru", undefined, ok, [], missing));
const n = (h.match(/верси[ияю] для проверки/g) || []).length;
assert.ok(n > 0);
assert.equal((h.match(/верси[ияю] для проверки \(копия сайта, где команда проверяет изменения\)/g) || []).length, n);
});
}
test("BRM-139: на главной нет номеров задач и служебных слов ни на одном языке", () => {
for (const lang of ["ru", "kk", "en"]) {
const h = text(homePage(lang, undefined, ok, [], { telegram: "chat", linkedin: "author" }));
assert.doesNotMatch(h, /BRM-\d+|выкладк|ключ доступа|access key|қолжетімділік кілті/i, lang);
}
});