SHA256
Отключить мультиаккаунтность и уточнить статусы профиля
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { profileCardHtml } from '../js/components/profile-card.js';
|
||||
import { accountRoleFromHeader, confirmationRights } from '../js/services/account-voting.js';
|
||||
|
||||
test('only explicit HEADER V3 type 1 is Primary; no legacy fallbacks', () => {
|
||||
@@ -14,7 +15,7 @@ test('confirmation permissions match all actor and target categories', () => {
|
||||
for (const a of types) for (const b of types) for (const as of statuses) for (const bs of statuses) {
|
||||
const actor = { login: 'A@free', accountRole: accountRoleFromHeader(a), shineStatus: as };
|
||||
const target = { login: 'B@free', accountRole: accountRoleFromHeader(b), shineStatus: bs };
|
||||
assert.deepEqual(confirmationRights(actor, target), { primary: a === 1 && b === 1, shine: a === 1 && b === 1 && as === 'shining' && bs !== 'not_interested' });
|
||||
assert.deepEqual(confirmationRights(actor, target), { primary: a === 1 && b === 1, shine: a === 1 && as === 'shining' && bs === 'shining' });
|
||||
assert.deepEqual(confirmationRights(actor, { ...target, login: 'a@FREE' }), { primary: false, shine: false });
|
||||
}
|
||||
assert.deepEqual(confirmationRights(null, null), {primary:false,shine:false});
|
||||
@@ -22,10 +23,31 @@ test('confirmation permissions match all actor and target categories', () => {
|
||||
test('profile has no official toggle; both confirmation actions enforce shared rules', () => {
|
||||
const src = name => readFileSync(new URL(`../js/pages/${name}`, import.meta.url), 'utf8');
|
||||
const profile = src('profile-edit-view.js');
|
||||
assert.match(profile, /<span class="badge is-no" data-status="account_role">/);
|
||||
assert.doesNotMatch(profile, /accountRoleBtn\.addEventListener/);
|
||||
assert.match(profile, /class="badge profile-account-info is-no" data-status="account_role"/);
|
||||
assert.doesNotMatch(profile, /saveProfileStatus\(login, 'account_role'/);
|
||||
const relations = src('user-relation-manage-view.js');
|
||||
assert.match(relations, /confirmationRights\(selfCard, targetCard\)/);
|
||||
assert.match(relations, /!rights\.primary/);
|
||||
assert.match(relations, /!rights\.shine/);
|
||||
});
|
||||
|
||||
|
||||
test('status cards show only declared statuses; unofficial shining accounts only show received confirmations', () => {
|
||||
for (const isSelf of [true, false]) for (const official of [true, false]) for (const shining of [true, false]) {
|
||||
const html = profileCardHtml({ isSelf, card: { login: 'test@free', accountRole: official ? 'primary' : 'non_voting', shineStatus: shining ? 'shining' : 'unknown', stats: { primaryReceivedCount: 9, primaryGivenCount: 9, shineReceivedCount: 9, shineGivenCount: 9 } } });
|
||||
assert.equal(html.includes('data-profile-list="primary_received"'), official);
|
||||
assert.equal(html.includes('data-profile-list="primary_given"'), official);
|
||||
assert.equal(html.includes('data-profile-list="shine_received"'), shining);
|
||||
assert.equal(html.includes('data-profile-list="shine_given"'), official && shining);
|
||||
}
|
||||
});
|
||||
test('multi-profile mode is disabled at the direct route and session switching entry points', () => {
|
||||
const read = path => readFileSync(new URL('../js/' + path, import.meta.url), 'utf8');
|
||||
const state = read('state.js');
|
||||
assert.match(state, /MULTI_PROFILE_ENABLED = false/);
|
||||
assert.match(state, /switchToSavedProfile\(login\) \{\s*if \(!MULTI_PROFILE_ENABLED\) throw/);
|
||||
assert.match(state, /prepareAddProfileLogin\(\) \{\s*if \(!MULTI_PROFILE_ENABLED\) throw/);
|
||||
assert.match(state, /await terminateCurrentSession\(\{ closeServerSession: true, notifySessionReset: false \}\)/);
|
||||
assert.doesNotMatch(read('pages/profile-view.js'), /data-self-profile-action="profiles"/);
|
||||
assert.doesNotMatch(read('app.js'), /switchToSavedProfile\(/);
|
||||
});
|
||||
|
||||
@@ -3,17 +3,20 @@ import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
const read = relative => expandRussian(fs.readFileSync(new URL(relative, import.meta.url), 'utf8'));
|
||||
test('выбор тарифа перед шагом 1, всего четыре шага', () => {
|
||||
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(login, /createRegistrationStepper\(3\)/);
|
||||
assert.match(email, /createRegistrationStepper\(4\)/);
|
||||
assert.match(payment, /createRegistrationStepper\(4\)/);
|
||||
assert.match(login, /createRegistrationStepper\(1,/);
|
||||
assert.match(login, /createRegistrationStepper\(2,/);
|
||||
assert.match(login, /createRegistrationStepper\(3,/);
|
||||
assert.match(login, /createRegistrationStepper\(4, 5\)/);
|
||||
assert.match(login, /if \(draft.accountType === 1\) showPreviousAccounts\(\)/);
|
||||
assert.match(login, /else if \(draft.accountType === 0\) \{ draft.previousAccounts = \[\]; finishIdentity/);
|
||||
assert.match(email, /createRegistrationStepper\(state\.registrationDraft\.accountType === 1 \? 5 : 4,/);
|
||||
assert.match(payment, /createRegistrationStepper\(state\.registrationDraft\.accountType === 1 \? 5 : 4,/);
|
||||
});
|
||||
test('реальная почта и 256-символьный лимит сохранены', () => {
|
||||
const email = read('../js/pages/registration-email-view.js');
|
||||
|
||||
Reference in New Issue
Block a user