Отключить мультиаккаунтность и уточнить статусы профиля

This commit is contained in:
AidarKC
2026-11-27 13:22:15 +03:00
parent ae430e84c7
commit 91a8bb9c3c
40 changed files with 312 additions and 383 deletions
+25 -3
View File
@@ -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\(/);
});