SHA256
Личный чат: голосовые с прослушиванием на паузе, фон «Северное сияние», запрет автоперевода
- Запись голосового: микрофон едет за пальцем, при отмене падает в корзину, с полпути пружинит обратно, а запись продолжается в режиме замка. На паузе запись можно прослушать и перемотать до отправки. - Фон «Северное сияние» для тёмной и светлой темы: отправленные сообщения зелёные, входящие голубые. Отблески у кромки сообщений вынесены в общий блок has-dm-flash. - Расшифрованная переписка помечена translate="no": автоперевод браузера отправлял бы её на сервер переводчика. Язык страницы объявляется сразу в index.html. Формат SHiNE_DM и серверный API не менялись. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@ 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 source = (path) => readFileSync(new URL(path, import.meta.url), 'utf8').replace(/\r\n/g, '\n');
|
||||
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'));
|
||||
@@ -57,6 +57,28 @@ test('замок — значок приложения, шрифт справк
|
||||
}
|
||||
});
|
||||
|
||||
test('расшифрованная переписка не уходит в автоперевод браузера', () => {
|
||||
for (const owner of ['screen', 'form', 'header']) assert.ok(chat.includes(`${owner}.translate = false;`), owner);
|
||||
for (const id of ['chat-forward-modal', 'chat-external-link-modal']) assert.match(chat, new RegExp(`id="${id}" translate="no"`));
|
||||
for (const page of ['messages-list', 'chat-media-view']) assert.match(source(`../js/pages/${page}.js`), /screen\.translate = false;/, page);
|
||||
});
|
||||
|
||||
test('страница с первой секунды объявляет язык приложения', () => {
|
||||
const index = source('../index.html');
|
||||
const script = index.slice(index.indexOf('(function applyLanguageBeforePaint() {'), index.indexOf('}());', index.indexOf('applyLanguageBeforePaint')) + 5);
|
||||
const key = source('../js/i18n/index.js').match(/const STORAGE_KEY = '([^']+)'/)[1];
|
||||
const langFor = (saved, languages) => {
|
||||
const document = { documentElement: { lang: 'en' } };
|
||||
const localStorage = { getItem: (name) => (name === key ? saved : null) };
|
||||
new Function('document', 'localStorage', 'navigator', script)(document, localStorage, { languages });
|
||||
return document.documentElement.lang;
|
||||
};
|
||||
assert.equal(langFor(null, ['ru-RU', 'en-US']), 'ru');
|
||||
assert.equal(langFor('en', ['ru-RU']), 'en', 'выбор в приложении важнее языка браузера');
|
||||
assert.equal(langFor(null, ['de-DE', 'ru']), 'ru', 'неподдерживаемый язык пропускается, как в js/i18n');
|
||||
assert.equal(langFor(null, ['de-DE']), 'en');
|
||||
});
|
||||
|
||||
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/);
|
||||
|
||||
Reference in New Issue
Block a user