Files
SHiNE-server/shine-UI/tests/dm-security-notice.test.mjs
T
PixelandClaude Opus 5.5 d09431da65 Личный чат: фоны «Затмение» и «Гроза», новая справка о шифровании, плавное сворачивание «Поддержки»
- Фоны «Затмение» и «Гроза» в двух темах. Сообщения, голосовые и поле ввода подхватывают свет фона:
  общий материал has-dm-glow, у фона только пять цветов на тему.
- Срок вложения и время — в одной строке; свечение пузырей не срезается краем ленты.
- Справка о шифровании: замок-значок вместо эмодзи, шрифт Source Serif 4 из файлов приложения (OFL).
- Карточка «Поддержка» сворачивается мягко и без рывка в конце: анимируется только её добавка к строке.

Версия клиента 1.21.18.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 18:12:58 +03:00

64 lines
4.0 KiB
JavaScript

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', 'zero_knowledge_label', 'zero_knowledge', 'self_custody_label', 'self_custody', 'control_label', 'control']) {
assert.ok(typeof note[key] === 'string' && note[key].trim(), `${locale}/${key}`);
}
});
}
test('русский текст DM соответствует утверждённой пользователем редакции от 27.11.2026', () => {
assert.deepEqual(ru.screens.chat_view.security_notice, {
"title": "Ваша переписка защищена сквозным шифрованием",
"zero_knowledge_label": "Zero-Knowledge Architecture:",
"zero_knowledge": "Мы не доверяем серверам. SHiNE не хранит ваши приватные ключи и технически не имеет доступа к содержимому чатов.",
"self_custody_label": "Self-Custody & Open Source:",
"self_custody": "Ваш ключ генерируется локально из вашего логина и пароля. Никаких скрытых алгоритмов — код полностью открыт.",
"control_label": "Absolute Control:",
"control": "Забудете пароль — навсегда потеряете доступ к переписке."
});
// Текст должен отображаться напрямую через textContent, без HTML-сущностей.
for (const text of Object.values(ru.screens.chat_view.security_notice)) {
assert.doesNotMatch(text, /&#(?:x[0-9a-f]+|\d+);/iu);
}
});
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('замок — значок приложения, шрифт справки лежит в приложении, а не грузится со стороны', () => {
const body = chat.slice(chat.indexOf('function createDmEncryptionNotice()'), chat.indexOf('function renderLog('));
assert.match(body, /iconHtml\('lock'\)/);
assert.doesNotMatch(body, /🔒/u);
const fonts = [...css.matchAll(/@font-face \{[^}]*url\("([^"]+)"\)/g)].map(([, path]) => path);
assert.equal(fonts.length, 2, 'кириллица и латиница');
for (const path of fonts) {
assert.match(path, /^\.\.\/\.\.\/assets\/fonts\//);
const data = readFileSync(new URL(path, new URL('../styles/features/', import.meta.url)));
assert.equal(data.toString('latin1', 0, 4), 'wOF2', path);
}
});
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/);
});