Поправил шрифты и некоторые визуальные косяки
This commit is contained in:
94
frontend/tests/ui-consistency.test.mjs
Normal file
94
frontend/tests/ui-consistency.test.mjs
Normal file
@@ -0,0 +1,94 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import test from 'node:test';
|
||||
|
||||
const readFrontendFile = relativePath => readFile(
|
||||
new URL(`../${relativePath}`, import.meta.url),
|
||||
'utf8'
|
||||
);
|
||||
|
||||
test('все пользовательские оболочки завершают каскад единой визуальной основой', async () => {
|
||||
const entrypoints = [
|
||||
['index.html', 'ui-foundation.css'],
|
||||
['admin/index.html', '../ui-foundation.css'],
|
||||
['admin/settings/index.html', '../../ui-foundation.css'],
|
||||
['teacher/index.html', '../ui-foundation.css'],
|
||||
['student/index.html', '../ui-foundation.css']
|
||||
];
|
||||
|
||||
for (const [file, expectedHref] of entrypoints) {
|
||||
const html = await readFrontendFile(file);
|
||||
const stylesheets = Array.from(
|
||||
html.matchAll(/<link\b[^>]*rel="stylesheet"[^>]*href="([^"]+)"[^>]*>/g),
|
||||
match => match[1]
|
||||
);
|
||||
|
||||
assert.equal(stylesheets.at(-1), expectedHref, file);
|
||||
}
|
||||
});
|
||||
|
||||
test('единая визуальная основа фиксирует типографику, размеры и доступный фокус', async () => {
|
||||
const foundation = await readFrontendFile('ui-foundation.css');
|
||||
|
||||
assert.match(foundation, /--ui-font-sans:/);
|
||||
assert.match(foundation, /--ui-control-sm:\s*32px/);
|
||||
assert.match(foundation, /--ui-control-md:\s*40px/);
|
||||
assert.match(foundation, /--ui-control-lg:\s*48px/);
|
||||
assert.match(foundation, /\.btn-sm\s*\{[^}]*min-height:\s*var\(--ui-control-sm\)/s);
|
||||
assert.match(foundation, /\.btn-md\s*\{[^}]*min-height:\s*var\(--ui-control-md\)/s);
|
||||
assert.match(foundation, /\.btn-lg\s*\{[^}]*min-height:\s*var\(--ui-control-lg\)/s);
|
||||
assert.match(foundation, /:focus-visible\s*\{[^}]*outline:/s);
|
||||
assert.match(foundation, /prefers-reduced-motion:\s*reduce/);
|
||||
});
|
||||
|
||||
test('локальные стили используют общие шрифтовые токены', async () => {
|
||||
const files = [
|
||||
'style.css',
|
||||
'student/style.css',
|
||||
'teacher/style.css',
|
||||
'admin/css/main.css',
|
||||
'admin/settings/css/main.css',
|
||||
'admin/css/schedule-quality.css',
|
||||
'admin/css/schedule-versions.css'
|
||||
];
|
||||
|
||||
for (const file of files) {
|
||||
const css = await readFrontendFile(file);
|
||||
assert.doesNotMatch(css, /font-family:\s*(?:['"]?Inter|['"]?Segoe UI|Georgia|['"]Times New Roman)/, file);
|
||||
}
|
||||
});
|
||||
|
||||
test('архивные действия и кнопки закрытия используют системные размеры', async () => {
|
||||
const actionSources = await Promise.all([
|
||||
readFrontendFile('admin/js/views/classrooms.js'),
|
||||
readFrontendFile('admin/js/views/groups.js'),
|
||||
readFrontendFile('admin/js/views/users.js')
|
||||
]);
|
||||
|
||||
actionSources.forEach(source => {
|
||||
assert.match(source, /class="btn btn-sm btn-secondary btn-restore-/);
|
||||
});
|
||||
|
||||
const modalViews = await Promise.all([
|
||||
'admin/views/academic-calendar.html',
|
||||
'admin/views/classrooms.html',
|
||||
'admin/views/groups.html',
|
||||
'admin/views/schedule.html',
|
||||
'admin/views/schedule-versions.html',
|
||||
'admin/views/subjects.html',
|
||||
'admin/views/university-structure.html',
|
||||
'admin/settings/views/time-slots.html'
|
||||
].map(readFrontendFile));
|
||||
|
||||
const closeButtons = modalViews.flatMap(html => Array.from(
|
||||
html.matchAll(/<button\b[^>]*class="[^"]*(?:modal-close|version-modal-close|settings-modal-close)[^"]*"[^>]*>/g),
|
||||
match => match[0]
|
||||
));
|
||||
|
||||
assert.ok(closeButtons.length > 0);
|
||||
closeButtons.forEach(button => {
|
||||
assert.match(button, /type="button"/);
|
||||
assert.match(button, /class="[^"]*\bbtn\b[^"]*\bbtn-icon-md\b/);
|
||||
assert.match(button, /aria-label="Закрыть окно"/);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user