Files
SHiNE-server/shine-UI/tests/registration-three-steps.test.mjs
T

46 lines
2.6 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs';
const read = relative => fs.readFileSync(new URL(relative, import.meta.url), 'utf8');
test('выбор аккаунта перед шагом 1, всего три шага', () => {
const choice = read('../js/pages/registration-choice-view.js');
const login = read('../js/pages/register-view.js');
const email = read('../js/pages/registration-email-view.js');
const payment = read('../js/pages/registration-payment-view.js');
assert.doesNotMatch(choice, /createRegistrationStepper\(/);
assert.match(login, /createRegistrationStepper\(1\)/);
assert.match(login, /createRegistrationStepper\(2\)/);
assert.match(email, /createRegistrationStepper\(3\)/);
assert.match(payment, /createRegistrationStepper\(3\)/);
});
test('реальная почта и 256-символьный лимит сохранены', () => {
const email = read('../js/pages/registration-email-view.js');
const passwords = read('../js/services/password-words.js');
assert.match(email, /startFreeRegistration\(/);
assert.match(email, /confirmFreeRegistration\(/);
assert.match(passwords, /PASSWORD_MAX_LENGTH = 256/);
});
test('пароль допускает один символ, а email можно изменить без устаревшего запроса', () => {
const registration = read('../js/pages/register-view.js');
const email = read('../js/pages/registration-email-view.js');
assert.match(registration, /value\.length < 1/);
assert.doesNotMatch(registration, /value\.length < 12/);
assert.match(registration, /input\.type = 'text'/);
assert.match(email, /let emailRequestId = 0/);
assert.match(email, /requestId !== emailRequestId/);
assert.match(email, /emailRequestId \+= 1/);
});
test('старт регистрации использует иллюстрацию и русское название', () => {
const intro = read('../js/pages/registration-intro-view.js');
assert.match(intro, /registration-sunrise-space\.png/);
assert.match(intro, /Добро пожаловать в Сияние/);
assert.match(intro, /Ваши публикации, сообщения и лайки хранятся вечно/);
assert.doesNotMatch(intro, /SHiNE\//);
});
test('экран поздравления объясняет различие статусов', () => {
const finish = read('../js/pages/registration-success-view.js');
assert.match(finish, /registrationSuccess\?\.flowType === 'paid'/);
assert.match(finish, /Arweave/);
assert.match(finish, /PDA/);
});