pages test: look for raw labels one text node at a time

The check joined whole panels' textContent, so a NOC log line ending in a
full stop ran into its timestamp ('facendo.' + 'proprio ora') and read as a
label. The new cities moved the seeded game onto such a line in Italian.
This commit is contained in:
Frederic Jung 2026-11-03 10:43:45 +00:00
parent 823e4188be
commit b7e5f193b4
No known key found for this signature in database

View file

@ -78,7 +78,9 @@ test('pages: the shipped page and dictionaries, with labels shrunk to ids, still
for (const [lang, word] of [['en', 'Customers'], ['it', 'Clienti'], ['fr', null]]) {
const { ev, errors } = load(lang === 'en' ? { file } : { file, lang, dir });
ev("ACT.start({});S.cash=1e8;ACT.launchBB({city:'fra'});for(let i=0;i<40;i++)dayTick();ACT.leftTab({t:'noc'});renderAll()");
const text = ev("['hud','leftBody','panelBody','modalCard','toasts'].map(i=>document.getElementById(i)?.textContent||'').join(' ')");
// Text node by text node: a raw label sits inside one, while two elements' text run together ("facendo." then
// "proprio ora") only looks like one.
const text = ev("['hud','leftBody','panelBody','modalCard','toasts'].map(i=>{const e=document.getElementById(i);if(!e)return '';const w=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),out=[];while(w.nextNode())out.push(w.currentNode.nodeValue);return out.join(' ');}).join(' ')");
if (word) assert.ok(text.includes(word), `${lang}: ${word}`);
assert.doesNotMatch(text, /\b[a-z_]+\.[a-z0-9_]{6,}\b/, `${lang}: no raw labels`);
assert.equal(ev("tr(FLOOD_WHO[0])"), ev("tr('failures.a_botnet_of_40_000_smart')"), `${lang}: labels kept for saves still translate`);