import {test} from 'node:test'; import assert from 'node:assert/strict'; import {createApp} from '../profile-server.mjs'; test('Сценарий: Пропуск регистрации — дневник без учётной записи; Личный дневник по-прежнему закрыт', async t => { const server = createApp({database:':memory:'}); await new Promise(r=>server.listen(0,'127.0.0.1',r)); t.after(()=>new Promise(r=>server.close(r))); const origin = `http://127.0.0.1:${server.address().port}`; const guest = await fetch(origin+'/guest?goal=lose'); assert.equal(guest.status,200); const html = await guest.text(); assert.match(html,/window\.TPTGuest=\{"goal":"lose"\}/); assert.doesNotMatch(html,/TPTProfile=/); const policy = guest.headers.get('content-security-policy'); assert.match(policy,/script-src 'self' 'sha256-/); assert.match(await (await fetch(origin+'/guest?goal=