de5ab9186c
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 10s
CI / integration (pull_request) Successful in 21s
CI / ui (pull_request) Successful in 1m14s
CI / conformance (pull_request) Successful in 10s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m48s
Add English versions of the privacy policy, EULA and offer (ui/legal/*_en.md) and render each legal page as one self-contained bilingual document: both language bodies plus a header language toggle and theme toggle (no back), a small inline ES5 script that switches language client-side (no reload, default Russian + persisted) and applies the theme (system default + persisted override) — mirroring the landing. The offer's English view transliterates the Russian product names spliced from the live catalog. renderLegalHtml now takes both language sources; renderOffer splices the price list into both; the renderer bakes and reads the _en sources and pre-renders the static pages at boot. Also wrap the /offer/ contour probe in the same retry+timeout as the legal probe (the offer page is now bilingual and larger). Docs + renderer/ui tests updated.
32 lines
2.0 KiB
JavaScript
32 lines
2.0 KiB
JavaScript
// Unit test for the public-offer page assembly: renderOffer splices the backend's price-list markdown
|
|
// into BOTH language sources of the offer at the pricing marker and renders them with the shared
|
|
// renderOfferHtml (bundled from ui/src/lib/offer). The prose rendering itself is unit-tested in ui/
|
|
// (offer.test.ts); here we assert the substitution reaches both languages and the tables render.
|
|
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { renderOffer, pricingMarker } from '../src/offer.mjs';
|
|
|
|
const tables =
|
|
'| Наименование | Рубли | Голоса в VK | Stars в Telegram |\n' +
|
|
'| --- | --- | --- | --- |\n' +
|
|
'| 50 «Фишек» | 200.00 | 30 | 100 |';
|
|
|
|
test('splices the price list into both language sources and renders the tables', () => {
|
|
const ru = `# Публичная оферта\n\n**4.4.** Стоимость Товаров:\n\n${pricingMarker}\n`;
|
|
const en = `# Public offer\n\n**4.4.** Cost of the Goods:\n\n${pricingMarker}\n`;
|
|
const html = renderOffer(ru, en, tables);
|
|
// The marker is gone from both languages and the projected table reached the document.
|
|
assert.ok(!html.includes(pricingMarker), 'the pricing marker must be substituted in both languages');
|
|
assert.ok(html.includes('<table>'), 'the price list must render as an HTML table');
|
|
assert.ok(html.includes('<td>200.00</td>'), 'a rouble price cell must be present');
|
|
assert.ok(html.includes('50 «Фишек»'), 'the product title must be present');
|
|
assert.ok(html.includes('<h1>Публичная оферта</h1>'), 'the Russian heading rendered');
|
|
assert.ok(html.includes('<h1>Public offer</h1>'), 'the English heading rendered');
|
|
assert.ok(html.includes('<!doctype html>'));
|
|
});
|
|
|
|
test('a "$" in a title is substituted literally, not as a replacement pattern', () => {
|
|
const html = renderOffer(`ru ${pricingMarker}`, `en ${pricingMarker}`, '| $5 pack | 1 |');
|
|
assert.ok(html.includes('$5 pack'), 'a "$" in the tables must survive substitution');
|
|
});
|