SHA256
Шесть абзацев заменены тремя пунктами: Zero-Knowledge Architecture, Self-Custody & Open Source, Absolute Control (ru/en). Формулировка «не имеет доступа к содержимому чатов» — сервер видит метаданные, но не содержимое. Тест обновлён под редакцию от 27.11.2026. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
3.2 KiB
JavaScript
51 lines
3.2 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('уведомление имеет собственные серые стили и не оформляется как 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/);
|
|
});
|