import test from 'node:test'; import assert from 'node:assert/strict'; import { readFileSync } from 'node:fs'; import { validateLoginOrThrow } from '../server-ui/js/server-ui-shared.js'; const read = p => readFileSync(new URL(p, import.meta.url), 'utf8'); test('server UI принимает полные логины и legacy при обновлении', () => { assert.equal(validateLoginOrThrow('server@shine'), 'server@shine'); assert.equal(validateLoginOrThrow('old_server'), 'old_server'); assert.throws(() => validateLoginOrThrow('x'.repeat(26)+'@shine')); assert.throws(() => validateLoginOrThrow('server@@shine')); assert.throws(() => validateLoginOrThrow('server.name@shine')); }); test('форма создания требует namespace type1 и правильный fee payer', () => { const page = read('../server-ui/js/create-server-pda-page.js'); const service = read('../js/services/shine-user-pda-service.js'); const html = read('../server-ui/create-server-pda.html'); assert.match(page, /namespace\.type !== 1/); assert.match(page, /getNamespace\(/); assert.match(html, /maxlength="30"/); assert.match(service, /feePayerPrivatePkcs8B64: keyBundle\.clientPair\.privatePkcs8B64/); });