Files
SHiNE-server/shine-UI/tests/session-resume.test.mjs

19 lines
1.1 KiB
JavaScript

import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import test from 'node:test';
const auth = readFileSync(new URL('../js/services/auth-service.js', import.meta.url), 'utf8');
test('resumeSession загружает материал до вычисления targetSessionId и поддерживает выбранную сессию', () => {
const method = auth.match(/async resumeSessionUnlocked\(login, preferredSessionId = ''\) \{[\s\S]*?\n \}/)?.[0] || '';
assert.ok(method, 'метод resumeSessionUnlocked должен существовать');
assert.match(method, /const requestedSessionId = String\(preferredSessionId \|\| ''\)\.trim\(\);/);
assert.match(method, /loadSessionMaterial\(cleanLogin, requestedSessionId\)/);
assert.match(method, /const targetSessionId = requestedSessionId \|\| sessionMaterial\.sessionId;/);
assert.ok(
method.indexOf('loadSessionMaterial(cleanLogin, requestedSessionId)')
< method.indexOf('const targetSessionId = requestedSessionId || sessionMaterial.sessionId;'),
'session material должен загружаться до вычисления targetSessionId',
);
});