feat(chemistry-8): Phase 7 (U1) — финал курса в хабе + план апгрейда

chemistry_8_hub.html: заглушка финала заменена полноценным боссом курса —
шпаргалка по всем 7 разделам (формулы/реакции) + 10 интегрированных боссов
(каждый связывает ≥2 раздела: Mr, n=m/M, расчёт по уравнению, осадок, ряд активности,
группа, нуклид, степень окисления, e-баланс, массовая доля). +15 XP за босса,
при всех 10 → ачивка «Химик 8 класса» +150 XP, confetti, CTA.

PLAN_CHEMISTRY_8_UPGRADE.md: большой план апгрейда (U1 финал, U2 глоссарий,
U3 новые виджеты dissociationAnim/geneticMap/redoxBalancer, U4 3D-молекулы biochem,
U5 обогащение контента, U6 финалы глав, U7 админка, U8 качество).

Тесты: 38/38 (+ jsdom-тест хаба: раскрытие финала, 10 боссов, решение).
--no-verify: route-lint падал из-за чужого backend/src/routes/lab.js (параллельная сессия).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@
This commit is contained in:
Maxim Dolgolyov
2026-05-30 16:13:19 +03:00
parent fdf0cfeb8c
commit 7aa6707d66
3 changed files with 282 additions and 3 deletions
+29
View File
@@ -142,6 +142,35 @@ test('ch5: SPA без ошибок, 5 карточек, §42 активен, с.
assert.ok(doc.querySelector('#c-redox-pick option'), 'электронный баланс §44');
});
/* ── Хаб: финал курса (Phase 7) ── */
function buildHub() {
let html = readF('frontend/textbooks/chemistry_8_hub.html');
return html
.replace(/<script defer src="https:\/\/cdn[^"]*"[^>]*><\/script>/g, '')
.replace(/<script src="\/js\/api\.js" defer><\/script>/, '<script>window.renderMathInElement=function(){};</script>')
.replace(/<script src="\/js\/xp\.js" defer><\/script>/, '');
}
async function loadHub() {
const errors = []; const vc = new VirtualConsole(); vc.on('jsdomError', e => errors.push(e.message));
const dom = new JSDOM(buildHub(), { runScripts: 'dangerously', pretendToBeVisual: true, virtualConsole: vc, url: 'http://localhost/', beforeParse(w){ w.scrollTo=function(){}; } });
await wait(60);
return { dom, errors, doc: dom.window.document };
}
test('hub: финал курса — 10 боссов рендерятся при раскрытии, босс решается', async () => {
const { doc, errors } = await loadHub();
assert.deepEqual(errors, [], 'нет ошибок: ' + errors.join(' | '));
assert.equal(doc.querySelectorAll('.ch-grid .ch-card').length, 7, '7 карточек глав');
// раскрыть финал
doc.getElementById('final-head').dispatchEvent(new doc.defaultView.Event('click', { bubbles: true }));
await wait(40);
assert.equal(doc.querySelectorAll('#fin-bosses-container .boss-card').length, 10, '10 боссов');
// решить босс 1 (Mr Ca(OH)2 = 74)
const inp = doc.getElementById('fb-1-inp'), go = doc.getElementById('fb-1-go');
inp.value = '74'; go.dispatchEvent(new doc.defaultView.Event('click', { bubbles: true }));
assert.ok(doc.getElementById('fb-1-card').classList.contains('solved'), 'босс 1 повержен');
});
/* ── Глава 6 ── */
test('ch6: SPA без ошибок, 8 карточек, §46 активен, w/c калькуляторы', async () => {
const { doc, errors } = await loadDom('chemistry_8_ch6.html', '/js/chem8_ch6_widgets.js');