openvibers/openvibe.trade Commits

Home: the Latest column's observation time is a real <time>, not escaped markup (it widened the table past the page at 1280 px; browser check) (#76)

OP OpenVibers committed 27 days ago · 5301f96ca4 · 2 files, +15 −1

Changes

ddiff --git a/server/render/views.js b/server/render/views.js
iindex 3857a01..8a4875e 100644
---- a/server/render/views.js
++++ b/server/render/views.js
@@@ -89,7 +89,7 @@ function home({ page, recent, urls, sync, pager, latest = new Map(), latestDocs
// The headline number when there is one; else the newest filing (most companies on a given day only filed); else
// nothing to show yet beyond the SEC's company list.
const latestCell = (i, o, d) => (o
-- ? html`<td class="num"><data value="${o.value}">${grouped(o.value)}</data> ${o.unit} <span class="muted">${labelOf(o.metric)}${o.period ? `, ${o.period}` : `, ${when(o.observed_at)}`}</span>${o.freshness && o.freshness.stale ? html` ${staleBadge(o.freshness)}` : ''}</td>`
++ ? html`<td class="num"><data value="${o.value}">${grouped(o.value)}</data> ${o.unit} <span class="muted">${labelOf(o.metric)}${o.period ? `, ${o.period}` : html`, ${when(o.observed_at)}`}</span>${o.freshness && o.freshness.stale ? html` ${staleBadge(o.freshness)}` : ''}</td>`
: d ? html`<td><a href="${urls.path.instrument(i)}#${d.id}">${d.form_type ? html`<span class="badge">${d.form_type}</span> ` : ''}filed ${when(d.published_at || d.first_seen_at)}</a></td>`
: html`<td><span class="muted">on the SEC's company list</span></td>`);
const rows = page.instruments.map((i) => html`<tr>
ddiff --git a/test/home-latest-cell.test.js b/test/home-latest-cell.test.js
nnew file mode 100644
iindex 0000000..81ff4c0
---- /dev/null
++++ b/test/home-latest-cell.test.js
@@@ -0,0 +1,14 @@
++'use strict';
++// The home's "Latest" column: a figure with no period names when it was observed as a real <time>, not as escaped
++// markup (the browser check of 2026-10-17 found "&lt;time datetime=…&gt;" text widening the table past the page).
++const assert = require('assert');
++const views = require('../server/render/views');
++
++const urls = { path: { instrument: (i) => `/i/${i.symbol}` } };
++const page = { instruments: [{ id: 1, symbol: 'AUD', name: 'Australian Dollar', kind: 'currency', exchange: null }] };
++const latest = new Map([[1, { value: 1.6172, unit: 'AUD', metric: 'rate', period: null, observed_at: '2026-10-17T00:00:00.000Z' }]]);
++const out = String(views.home({ page, recent: [], urls, sync: null, pager: null, latest }));
++const cell = out.slice(out.indexOf('<td class="num">'), out.indexOf('</td>', out.indexOf('<td class="num">')));
++assert.ok(cell.includes('<time datetime="2026-10-17T00:00:00.000Z">2026-10-17 00:00 UTC</time>'), cell);
++assert.ok(!out.includes('&lt;time'), 'no escaped markup');
++console.log('home latest cell: all checks passed');