brendmanager/test/contact.test.js
Peppa f89a38006a
All checks were successful
peppa/lint lint: success за 0с
peppa/test test: success за 2с
ci / checks (pull_request) Successful in 8s
deploy / deploy (pull_request) Successful in 15s
BRM-99: на главной видно, что вошла BRM-66
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-17 22:18:38 +05:00

30 lines
2.1 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, pageHtml, CONTACT_MAIL } from "../src/site.js";
test("Сценарий: способ связи одинаков на главной и на «Рынке», слова про задачу не встречаются", () => {
for (const lang of ["ru", "kk", "en"]) {
// BRM-87: «@» записан кодом (&#64; и %40), чтобы адрес не подменял Cloudflare
const dec = (h) => h.replaceAll("&#64;", "@").replaceAll("%40", "@");
const home = dec(homePage(lang));
const market = dec(pageHtml("market.html", lang));
assert.ok(home.includes(CONTACT_MAIL) && market.includes(CONTACT_MAIL), lang);
assert.ok(home.includes(`href="mailto:${CONTACT_MAIL}"`) && market.includes(`href="mailto:${CONTACT_MAIL}"`), lang);
assert.doesNotMatch(home + market, /к задаче|тапсырмаға|on the task/);
if (lang === "ru") assert.doesNotMatch((home + market).replace(/Что вошло в эту версию:[^<]*/, "").replace(/<[^>]+>/g, " "), /задач|BRM-\d+/i); // BRM-99: строка «Что вошло» называет задачу
}
});
test("Сценарий: с настоящим адресом в окружении пометки «адрес-пример» нет, а без него она остаётся", async () => {
const { execFileSync } = await import("node:child_process");
const run = (env) => execFileSync(process.execPath, ["--input-type=module", "-e",
`import { homePage, pageHtml } from "./src/site.js"; process.stdout.write(homePage("ru") + pageHtml("market.html", "ru"));`],
{ env: { PATH: process.env.PATH, ...env }, encoding: "utf8" });
const real = run({ CONTACT_EMAIL: "hello@brand.example" }).replaceAll("&#64;", "@").replaceAll("%40", "@");
assert.ok(real.includes('href="mailto:hello@brand.example"'));
assert.doesNotMatch(real, /адрес-пример/);
assert.doesNotMatch(real, /mockcontact/);
const mock = run({ CONTACT_EMAIL: "" });
assert.match(mock, /адрес-пример/);
});