feat(offer): live catalog price list in the public offer, served by the render sidecar
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 11s
CI / integration (pull_request) Successful in 26s
CI / ui (pull_request) Successful in 1m13s
CI / conformance (pull_request) Successful in 10s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Failing after 16m19s
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 11s
CI / integration (pull_request) Successful in 26s
CI / ui (pull_request) Successful in 1m13s
CI / conformance (pull_request) Successful in 10s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Failing after 16m19s
Robokassa moderation requires the public offer to list every digital good with its price. Move /offer/ off the static landing container to the render sidecar: it splices the live catalog price list (§4.4) into the owner-edited ui/legal/offer_ru.md and renders it with the shared ui/src/lib/offer.ts — one renderer, no drift, always matching the current catalog with no redeploy. - backend: /api/v1/internal/offer/pricing (internal, off the edge allow-list) projects the active catalog into two markdown tables — chip packs priced per rail (roubles / VK votes / Telegram Stars) and chip-priced values — through payments.Money so no float reaches the page. Cached in memory: warmed at boot, marked stale on every catalog mutation, so a served render issues no query. - renderer: GET /offer/ fetches the tables and substitutes them at the <#pricing_template#> marker, then renders; offer_ru.md is baked into the image and marked is bundled from ui. GET /offer -> 301. Only /offer/ is edge-exposed. - caddy: route /offer/ to the sidecar; drop the now-dead landing /offer/ handlers and the vite emit-offer plugin. - offer: fill §4.3 (the chip-payment wording) and drop the in-page back link. - landing footer: a feedback link (the offer's Telegram contact) beside the offer link. - docs (ARCHITECTURE, FUNCTIONAL +_ru, renderer README), CI /offer/ probe, unit + integration + node tests.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
// Unit test for the public-offer page assembly: renderOffer splices the backend's price-list
|
||||
// markdown into the offer at the pricing marker and renders it 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 and that the tables reach the rendered HTML.
|
||||
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 the offer and renders the tables to HTML', () => {
|
||||
const md = `# Публичная оферта\n\n**4.4.** Стоимость Товаров:\n\n${pricingMarker}\n`;
|
||||
const html = renderOffer(md, tables);
|
||||
// The marker is gone and the projected table reached the document as a real HTML table.
|
||||
assert.ok(!html.includes(pricingMarker), 'pricing marker must be substituted');
|
||||
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');
|
||||
// The offer chrome from the shared renderer is intact.
|
||||
assert.ok(html.includes('<!doctype html>'));
|
||||
});
|
||||
|
||||
test('a "$" in a title is substituted literally, not as a replacement pattern', () => {
|
||||
const html = renderOffer(`x ${pricingMarker} y`, '| $5 pack | 1 |');
|
||||
assert.ok(html.includes('$5 pack'), 'a "$" in the tables must survive substitution');
|
||||
});
|
||||
Reference in New Issue
Block a user