fix: preserve dated health results while update cache refreshes

This commit is contained in:
VAIO73
2026-10-28 17:30:44 +00:00
parent 43973e1d06
commit 889409de8d
6 changed files with 88 additions and 3 deletions
+15
View File
@@ -272,5 +272,20 @@ for (const [locale, expectedText] of [
check(`prefixed diagnostic preserved ${locale}`, () => assert.equal(
render('Updates: ' + opaque, locale), translator(locale)('healthStatus.categories.updates') + ': ' + opaque));
}
let summaryMapper;
walk(source,n=>{if(ts.isVariableDeclaration(n)&&n.name.getText(source)==='translateHealthSummary')summaryMapper=n.initializer;});
assert.ok(summaryMapper,'actual summary mapper handles the real bare Updates result');
const summaryFactory=new Function('t',compile('const translateHealthText='+emit(mapper,source)+';const translateHealthSummary='+emit(summaryMapper,source))+';return translateHealthSummary;');
for(const locale of ['sk','en']){
const t=translator(locale), summary=summaryFactory(t);
const detail='Reboot required: running 7.0.14-25-pve; installed 7.0.14-26-pve';
const value={summary:'Updates',details:{updates:{checks:{reboot_required:{status:'INFO',detail}}}}};
const before=JSON.stringify(value);
assert.equal(summary(value),t('healthStatus.hostUpdate.rebootKernel',{running:'7.0.14-25-pve',installed:'7.0.14-26-pve'}));
assert.equal(JSON.stringify(value),before,'rendering never mutates the snapshot');
assert.equal(summary({summary:'Updates',details:{}}),t('healthStatus.categories.updates'));
assert.equal(summary({summary:'Updates',details:{updates:{checks:{reboot_required:{status:'UNKNOWN',detail}}}}}),t('healthStatus.categories.updates'),'unknown evidence cannot create a reboot-required summary');
assert.equal(summary({summary:'opaque diagnostic',details:{}}),'opaque diagnostic');
}
if (failures) throw new Error(`${failures} health-text assertions failed`);
console.log(`PASS: actual health mapper/provider; ${new Set(cases.map(row => row[1])).size} new keys, ${cases.length} message variants, ${Object.keys(catalogs).length} shipped locales and unconditional missing-key fallback`);