Доработать UI личных сообщений

This commit is contained in:
AidarKC
2026-11-14 00:14:27 +03:00
parent 42a05a7a67
commit c972a975fd
9 changed files with 132 additions and 2 deletions
@@ -0,0 +1,34 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
const source = (path) => readFileSync(new URL(path, import.meta.url), 'utf8');
const chat = source('../js/pages/chat-view.js');
const css = source('../styles/features/chat.css');
const ru = JSON.parse(source('../js/i18n/locales/ru.json'));
const en = JSON.parse(source('../js/i18n/locales/en.json'));
for (const [locale, language] of [['ru', ru], ['en', en]]) {
test(`в ${locale} есть полный текст предупреждения DM`, () => {
const note = language.screens.chat_view.security_notice;
for (const key of ['title', 'encryption', 'servers', 'derivation', 'rotation', 'source', 'warning_label', 'warning', 'recovery']) {
assert.ok(typeof note[key] === 'string' && note[key].trim(), `${locale}/${key}`);
}
});
}
test('уведомление формируется только локально и добавляется первым элементом ленты', () => {
const start = chat.indexOf('function createDmEncryptionNotice()');
const end = chat.indexOf('function renderLog(', start);
const functionBody = chat.slice(start, end);
assert.ok(start >= 0 && end > start);
assert.match(functionBody, /document\.createElement\('aside'\)/);
assert.match(functionBody, /dm-security-notice/);
assert.match(chat, /list\.innerHTML = '';\s*list\.append\(createDmEncryptionNotice\(\)\);\s*const messages = getChatMessages\(chatId\);/);
assert.doesNotMatch(functionBody, /authService|addSignedMessageToChat|sendDirectMessage|AddBlock|fetch\(/);
});
test('уведомление имеет собственные серые стили и не оформляется как bubble', () => {
assert.match(css, /\.dm-security-notice\s*\{[\s\S]*?color: var\(--text-secondary\)/);
assert.doesNotMatch(chat.slice(chat.indexOf('function createDmEncryptionNotice()'), chat.indexOf('function renderLog(')), /className = ['"`]bubble/);
});