Filters: the panel is a bar (status segment, always visible) plus a body that lives as a layer under it - collapsed by default, expands on hover/focus/tap and never moves the case grid; the reset control appears only when a facet is limited; width capped at 720px (measured 45px slack against 477px before). Facet research report is included. Links: project links in the mini card and in the project window are icon-only buttons with a uniform slot (16px card / 18px window) and the accessible name in aria-label; studio contacts (mail, VK, RuStore) live outside the cards. Team and page: real photos from the public TITANS team page go to the member window while the card keeps the mascot; the portfolio gains the First Step Radio card and genre values, the process block became an individual-approach section, plus a cookie bar and a removable ticker. Design folders under design/ keep reports, measurements, scripts and the .pen; probe and before/after screenshot dumps, editor backups and caches are removed. Background-variant and palette previews stay until the client picks one.
452 lines
28 KiB
JavaScript
452 lines
28 KiB
JavaScript
/* Живая проверка знаков ресурсов и компактных кнопок-ссылок (§10.28, канбан t_d3adf730).
|
||
*
|
||
* Отвечает на пункты приёмки ЗАМЕРАМИ, а не описанием:
|
||
* 1. единый размер и вес: слот 16×16 (карточка) / 18×18 (окно), чернильный bbox внутри слота,
|
||
* alpha-масса всех четырёх знаков в одной полосе (растеризация ЖИВОГО DOM в canvas);
|
||
* 2. компактные кнопки: 1..3 ссылки в ряд — ширины кнопок, ряда, контейнера на 1440 и 390;
|
||
* 3. высоты кнопок прежние (36/48), target ≥24×24, :focus-visible, AA в обеих темах;
|
||
* 4. projectLinksHTML() — единственный сборщик: состав карточки == состав окна;
|
||
* 5. знак не крупнее кегля подписи: чернильный bbox vs font-size кнопки.
|
||
* Плюс: сетевые запросы против копии `git show HEAD:src/*`, JS-ошибки, превью в shots/.
|
||
*
|
||
* Запуск: node design/glyph-slot-2026-10-14/verify-glyph-slot.cjs (dev-server на 127.0.0.1:8765)
|
||
* Exit: 0 = все проверки прошли, 1 = есть провалы. Протокол пишется в verify-2026-10-14.md.
|
||
*/
|
||
const fs = require('fs');
|
||
const path = require('path');
|
||
const { launch } = require('./pw.cjs');
|
||
|
||
const BASE = process.env.PAGE_URL || 'http://127.0.0.1:8765';
|
||
const SHOTS = path.join(__dirname, 'shots');
|
||
if (!fs.existsSync(SHOTS)) fs.mkdirSync(SHOTS, { recursive: true });
|
||
const REPORT_MD = process.env.REPORT_MD || path.join(__dirname, 'verify-2026-10-14.md');
|
||
|
||
const FAILS = [];
|
||
const L = [];
|
||
const w = (s = '') => { L.push(s); console.log(s); };
|
||
|
||
/* Ожидаемый состав ссылок — content/projects/*.md; состав и порядок в этой волне не меняются */
|
||
const EXPECT = [
|
||
{ slug: 'bukvika', title: 'Буквика', links: [
|
||
['rustore', 'В RuStore', 'https://www.rustore.ru/catalog/app/ru.hmt.bukvika'],
|
||
['vk', 'Играть', 'https://vk.ru/app53786153']] },
|
||
{ slug: 'associations', title: 'Ассоциации', links: [
|
||
['vk', 'Играть', 'https://vk.ru/app54769031']] },
|
||
{ slug: 'first-step-radio', title: 'First Step Radio', links: [
|
||
['site', 'Сайт проекта', 'https://fsr.uzuron.com/'],
|
||
['rustore', 'В RuStore', 'https://www.rustore.ru/catalog/app/ru.hmt.fsr']] }
|
||
];
|
||
|
||
const MASS_SPREAD_MAX = 1.20; // полоса «одной оптической массы»
|
||
const INK_MARGIN_MIN = 0.4; // px воздуха от чернил до края слота
|
||
const CARD_BTN_H = 36, WIN_BTN_H = 48;
|
||
|
||
/* ---------- WCAG 2.x контраст, считается здесь (не читается со страницы) ---------- */
|
||
function rgb(s) { const m = (s.match(/[\d.]+/g) || [0, 0, 0]).slice(0, 3).map(Number); return m; }
|
||
function lum(c) { return c.map((v) => { v /= 255; return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4); })
|
||
.reduce((s, v, i) => s + v * [0.2126, 0.7152, 0.0722][i], 0); }
|
||
function ratio(a, b) { const l1 = lum(rgb(a)), l2 = lum(rgb(b)); return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05); }
|
||
|
||
/* ---------- baseline для сетевого диффа ---------- */
|
||
function ensureBaseline() {
|
||
const dir = path.join(__dirname, '..', '..', 'src-baseline');
|
||
if (fs.existsSync(path.join(dir, 'index.html'))) return dir;
|
||
fs.mkdirSync(path.join(dir, 'js'), { recursive: true });
|
||
fs.mkdirSync(path.join(dir, 'data'), { recursive: true });
|
||
const git = (spec, out) => {
|
||
const r = require('child_process').execSync('git show ' + spec, { cwd: path.join(__dirname, '..', '..'), encoding: 'buffer' });
|
||
fs.writeFileSync(out, r);
|
||
};
|
||
git('HEAD:src/index.html', path.join(dir, 'index.html'));
|
||
git('HEAD:src/js/main.js', path.join(dir, 'js', 'main.js'));
|
||
for (const f of ['form.js', 'planet.js']) git('HEAD:src/js/' + f, path.join(dir, 'js', f));
|
||
for (const f of ['projects.js', 'team.js']) git('HEAD:src/data/' + f, path.join(dir, 'data', f));
|
||
return dir;
|
||
}
|
||
function dropBaseline(dir) { if (process.env.KEEP_BASELINE !== '1') fs.rmSync(dir, { recursive: true, force: true }); }
|
||
|
||
async function collectRequests(url) {
|
||
const browser = await launch();
|
||
const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 } });
|
||
const page = await ctx.newPage();
|
||
const reqs = [];
|
||
page.on('request', (r) => reqs.push(r.url()));
|
||
await page.goto(url, { waitUntil: 'load' });
|
||
await page.waitForTimeout(1200);
|
||
await browser.close();
|
||
return reqs;
|
||
}
|
||
|
||
/* ---------------- страничные сниппеты (строки) ---------------- */
|
||
|
||
/* Растеризация ЖИВОГО знака внутри страницы: клон SVG получает явный размер слота
|
||
(CSS в data-URL не действует), рисуется в canvas с увеличением 24x;
|
||
возвращает alpha-массу (px²) и чернильный bbox (px слота). */
|
||
const PROBE_ICON_SRC = `async function (sel, S) {
|
||
const svg = document.querySelector(sel);
|
||
if (!svg) return null;
|
||
const clone = svg.cloneNode(true);
|
||
clone.setAttribute('style', 'display:block;width:' + S + 'px;height:' + S + 'px');
|
||
const str = new XMLSerializer().serializeToString(clone);
|
||
const url = 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(str)));
|
||
const SCALE = 24, px = Math.round(S * SCALE);
|
||
const img = new Image();
|
||
await new Promise(function (res, rej) { img.onload = res; img.onerror = rej; img.src = url; });
|
||
const c = document.createElement('canvas');
|
||
c.width = px; c.height = px;
|
||
const ctx = c.getContext('2d');
|
||
ctx.drawImage(img, 0, 0, px, px);
|
||
const d = ctx.getImageData(0, 0, px, px).data;
|
||
let sum = 0, minX = 1e9, minY = 1e9, maxX = -1, maxY = -1;
|
||
for (let y = 0; y < px; y++) for (let x = 0; x < px; x++) {
|
||
const a = d[(y * px + x) * 4 + 3];
|
||
if (a === 0) continue;
|
||
sum += a / 255;
|
||
if (x < minX) minX = x; if (x > maxX) maxX = x;
|
||
if (y < minY) minY = y; if (y > maxY) maxY = y;
|
||
}
|
||
const u = 1 / SCALE;
|
||
return {
|
||
mass: +(sum * u * u).toFixed(3),
|
||
inkW: +((maxX - minX + 1) * u).toFixed(2),
|
||
inkh: +((maxY - minY + 1) * u).toFixed(2),
|
||
margin: {
|
||
left: +(minX * u).toFixed(2), top: +(minY * u).toFixed(2),
|
||
right: +(S - (maxX + 1) * u).toFixed(2), bottom: +(S - (maxY + 1) * u).toFixed(2)
|
||
}
|
||
};
|
||
}`;
|
||
|
||
const PROBE_LINKS_SRC = `function (sel) {
|
||
const out = [];
|
||
document.querySelectorAll(sel).forEach(function (a) {
|
||
const svg = a.querySelector('svg.btn__icon');
|
||
const r = a.getBoundingClientRect();
|
||
const cs = getComputedStyle(a);
|
||
let bgEl = a, bg = 'rgba(0, 0, 0, 0)';
|
||
while (bgEl && (bg === 'rgba(0, 0, 0, 0)' || bg === 'transparent')) {
|
||
bg = getComputedStyle(bgEl).backgroundColor;
|
||
bgEl = bgEl.parentElement;
|
||
}
|
||
const g = svg ? svg.querySelector('g') : null;
|
||
out.push({
|
||
label: a.textContent.trim(), href: a.getAttribute('href'), ariaLabel: a.getAttribute('aria-label'),
|
||
cls: a.className, svg: !!svg,
|
||
viewBox: svg ? svg.getAttribute('viewBox') : null,
|
||
groupTf: g ? g.getAttribute('transform') : null,
|
||
pathFill: svg ? svg.querySelector('path').getAttribute('fill') : null,
|
||
ariaHidden: svg ? svg.getAttribute('aria-hidden') : null,
|
||
focusable: svg ? svg.getAttribute('focusable') : null,
|
||
prims: svg ? svg.querySelectorAll('path, circle, ellipse, rect').length : 0,
|
||
imgInside: a.querySelectorAll('img').length,
|
||
useExternal: svg ? svg.querySelectorAll('use, image').length : 0,
|
||
iconW: svg ? +svg.getBoundingClientRect().width.toFixed(2) : 0,
|
||
iconH: svg ? +svg.getBoundingClientRect().height.toFixed(2) : 0,
|
||
w: +r.width.toFixed(2), h: +r.height.toFixed(2),
|
||
fontSize: parseFloat(cs.fontSize), letterSpacing: cs.letterSpacing, pad: cs.padding,
|
||
btnGap: cs.gap, nowrap: cs.whiteSpace,
|
||
color: cs.color, bg: bg, borderColor: cs.borderTopColor,
|
||
outlineW: cs.outlineWidth, outlineStyle: cs.outlineStyle
|
||
});
|
||
});
|
||
return out;
|
||
}`;
|
||
|
||
const PROBE_ROW_SRC = `function (sel, extraLabel, firstSvgSel) {
|
||
const box = document.querySelector(sel);
|
||
if (!box) return null;
|
||
const gap = parseFloat(getComputedStyle(box).gap) || 0;
|
||
const rects = function () { return Array.from(box.children).map(function (k) { return k.getBoundingClientRect(); }); };
|
||
const bb = box.getBoundingClientRect();
|
||
const cur = rects();
|
||
const lineW = (rs) => +(rs.reduce(function (s, k) { return s + k.width; }, 0) + gap * (rs.length - 1)).toFixed(2);
|
||
const res = {
|
||
n: cur.length,
|
||
containerW: +bb.width.toFixed(2),
|
||
buttons: cur.map(function (k) { return +k.width.toFixed(2); }),
|
||
rowW: lineW(cur),
|
||
oneLine: cur.every(function (k) { return Math.abs(k.top - cur[0].top) < 1.5; }),
|
||
overflow: +(Math.max.apply(null, cur.map(function (k) { return k.right; })) - bb.right).toFixed(2)
|
||
};
|
||
if (extraLabel) {
|
||
const src = box.lastElementChild;
|
||
const clone = src.cloneNode(true);
|
||
const svg = clone.querySelector('svg');
|
||
const firstSvg = document.querySelector(firstSvgSel);
|
||
if (svg && firstSvg) svg.outerHTML = firstSvg.outerHTML;
|
||
clone.lastChild.nodeValue = extraLabel;
|
||
box.appendChild(clone);
|
||
const nx = rects(); // список берётся заново: клон уже в DOM
|
||
res.with3 = {
|
||
n: nx.length, rowW: lineW(nx),
|
||
oneLine: nx.every(function (k) { return Math.abs(k.top - nx[0].top) < 1.5; }),
|
||
overflow: +(Math.max.apply(null, nx.map(function (k) { return k.right; })) - bb.right).toFixed(2)
|
||
};
|
||
box.removeChild(box.lastElementChild);
|
||
}
|
||
return res;
|
||
}`;
|
||
|
||
const fn = (src) => 'return (' + src + ')';
|
||
|
||
(async () => {
|
||
w('# Проверка: знаки ресурсов — единый размер и вес, компактные кнопки-ссылки (§10.28)');
|
||
w();
|
||
w('Проект: `G:\\Project\\Haevey_Monster_Team_Page` · канбан `t_d3adf730` · 2026-10-14');
|
||
w('Живая страница `' + BASE + '/src/` + Playwright/Chromium (Chrome 148), растеризация знаков в canvas.');
|
||
w();
|
||
|
||
/* ---------- сеть ---------- */
|
||
w('## Сетевые запросы');
|
||
w();
|
||
const baseDir = ensureBaseline();
|
||
const nowReqs = await collectRequests(BASE + '/src/');
|
||
const baseReqs = await collectRequests(BASE + '/src-baseline/');
|
||
dropBaseline(baseDir);
|
||
const uniq = (a) => Array.from(new Set(a));
|
||
const nowU = uniq(nowReqs).map((u) => u.replace(/^https?:\/\/[^/]+/, ''));
|
||
const baseU = uniq(baseReqs).map((u) => u.replace(/^https?:\/\/[^/]+/, '').replace(/^\/src-baseline/, '/src'));
|
||
const added = nowU.filter((u) => !baseU.includes(u));
|
||
const iconish = uniq(nowReqs).filter((u) => /\.svg(\?|$)/i.test(u) || /icon|awesome|feather|lucide|icomoon|material-icons/i.test(u));
|
||
w('| Что | значение |');
|
||
w('|---|---|');
|
||
w('| запросов всего (текущая) | ' + uniq(nowReqs).length + ' |');
|
||
w('| запросов всего (копия `git show HEAD:src/*`) | ' + uniq(baseReqs).length + ' |');
|
||
w('| добавлено правкой | ' + (added.length ? added.join(', ') : '**нет**') + ' |');
|
||
w();
|
||
w('Иконки-запросы (svg/иконочные шрифты) среди запросов страницы: ' + (iconish.length ? '**' + iconish.join(', ') + '**' : 'нет — знаки инлайновые'));
|
||
w();
|
||
if (added.length) FAILS.push('новые сетевые запросы: ' + added.join(', '));
|
||
|
||
const browser = await launch();
|
||
const parity = [];
|
||
|
||
for (const vp of [{ w: 1440, h: 900 }, { w: 390, h: 844 }]) {
|
||
for (const theme of ['light', 'dark']) {
|
||
const ctx = await browser.newContext({ viewport: { width: vp.w, height: vp.h } });
|
||
const page = await ctx.newPage();
|
||
const jsErrors = [];
|
||
const badResp = [];
|
||
page.on('pageerror', (e) => jsErrors.push(String(e)));
|
||
page.on('console', (m) => { if (m.type() === 'error' && !/Failed to load resource/i.test(m.text())) jsErrors.push(m.text()); });
|
||
page.on('response', (r) => { if (r.status() >= 400) badResp.push(r.status() + ' ' + r.url()); });
|
||
await page.goto(BASE + '/src/', { waitUntil: 'load' });
|
||
await page.waitForTimeout(400);
|
||
if (theme === 'dark') {
|
||
if (vp.w > 767) await page.click('#theme-toggle');
|
||
else {
|
||
await page.click('.nav-toggle');
|
||
await page.waitForTimeout(250);
|
||
await page.click('#theme-toggle-panel');
|
||
await page.waitForTimeout(250);
|
||
await page.click('.nav-toggle');
|
||
}
|
||
await page.waitForTimeout(400);
|
||
}
|
||
const got = await page.evaluate(() => document.documentElement.getAttribute('data-theme') || 'light');
|
||
if (got !== theme) FAILS.push(vp.w + '/' + theme + ': тема не переключилась (data-theme=' + got + ')');
|
||
/* превью и замеры — на отгруженном состоянии, а не на кадре reveal-анимации (.reveal{opacity:0}) */
|
||
await page.addStyleTag({ content: '.reveal{opacity:1!important;translate:none!important;transition:none!important}' +
|
||
'*{transition:none!important;animation:none!important}' });
|
||
await page.evaluate(() => document.querySelectorAll('.reveal').forEach((e) => e.classList.add('is-visible')));
|
||
await page.waitForTimeout(120);
|
||
|
||
const tag = vp.w + '-' + theme;
|
||
w('### ' + vp.w + 'px · ' + theme);
|
||
w();
|
||
const cardMass = {};
|
||
|
||
/* ---------- мини-карточка: слот, масса, влезание, a11y ---------- */
|
||
for (const exp of EXPECT) {
|
||
const sel = '.case-card[data-slug="' + exp.slug + '"]';
|
||
await page.locator(sel).scrollIntoViewIfNeeded();
|
||
await page.waitForTimeout(260);
|
||
const links = await page.evaluate('(' + PROBE_LINKS_SRC + ')' + '(' + JSON.stringify(sel + ' .case-card__links a') + ')');
|
||
if (links.length !== exp.links.length) { FAILS.push(tag + '/' + exp.slug + ': ссылок ' + links.length + ', ожидалось ' + exp.links.length); continue; }
|
||
|
||
const line = [];
|
||
for (let i = 0; i < links.length; i++) {
|
||
const l = links[i];
|
||
const [kind, label, href] = exp.links[i];
|
||
const p = tag + '/' + exp.slug + '[' + i + ']';
|
||
if (l.label !== label) FAILS.push(p + ': подпись «' + l.label + '» != «' + label + '»');
|
||
if (l.href !== href) FAILS.push(p + ': href ' + l.href + ' != ' + href);
|
||
if (!l.svg) { FAILS.push(p + ': нет инлайнового svg.btn__icon'); continue; }
|
||
if (l.viewBox !== '0 0 24 24') FAILS.push(p + ': viewBox ' + l.viewBox + ' != «0 0 24 24» (единый слот)');
|
||
if (!l.groupTf || !/translate\(/.test(l.groupTf) || !/scale\(/.test(l.groupTf)) FAILS.push(p + ': знак не вписан группой translate/scale (' + l.groupTf + ')');
|
||
if (l.ariaHidden !== 'true' || l.focusable !== 'false') FAILS.push(p + ': aria-hidden/focusable не выставлены');
|
||
if (l.imgInside || l.useExternal) FAILS.push(p + ': знак не инлайновый (img/use/image)');
|
||
if (Math.abs(l.iconW - 16) > 0.5 || Math.abs(l.iconH - 16) > 0.5) FAILS.push(p + ': слот знака ' + l.iconW + '×' + l.iconH + ', ожидался квадрат 16×16');
|
||
if (l.w < 24 || l.h < 24) FAILS.push(p + ': hit-area ' + l.w + '×' + l.h + ' < 24×24');
|
||
if (Math.abs(l.h - CARD_BTN_H) > 1) FAILS.push(p + ': высота кнопки ' + l.h + ' px, ожидалось ' + CARD_BTN_H);
|
||
if (l.nowrap !== 'nowrap') FAILS.push(p + ': подпись может рваться внутри кнопки (white-space=' + l.nowrap + ')');
|
||
const cr = ratio(l.color, l.bg);
|
||
if (cr < 4.5) FAILS.push(p + ': контраст подписи ' + cr.toFixed(2) + ':1 < 4.5 (' + l.color + ' на ' + l.bg + ')');
|
||
|
||
const ink = await page.evaluate('(async function(s, S){ return (' + PROBE_ICON_SRC + ')(s, S); })' +
|
||
'(' + JSON.stringify(sel + ' .case-card__links a:nth-child(' + (i + 1) + ') svg.btn__icon') + ', 16)');
|
||
if (!ink) { FAILS.push(p + ': знак не растеризован'); continue; }
|
||
const air = Math.min(ink.margin.left, ink.margin.top, ink.margin.right, ink.margin.bottom);
|
||
if (air < INK_MARGIN_MIN) FAILS.push(p + ': чернила знака упираются в край слота (воздух ' + air + ' px < ' + INK_MARGIN_MIN + ')');
|
||
if (ink.inkh > l.fontSize + 0.01) FAILS.push(p + ': знак выше кегля подписи (' + ink.inkh + ' > ' + l.fontSize + ')');
|
||
if (ink.inkW > l.fontSize * 1.45) FAILS.push(p + ': знак шире кегля подписи (' + ink.inkW + ' > ' + l.fontSize + '×1.45)');
|
||
cardMass[kind] = ink.mass;
|
||
line.push('«' + l.label + '» ' + l.w + '×' + l.h + ', слот ' + l.iconW + '×' + l.iconH + ', чернила ' + ink.inkW + '×' + ink.inkh + ' (масса ' + ink.mass.toFixed(1) + '), ' + cr.toFixed(2) + ':1, кегль ' + l.fontSize + 'px');
|
||
}
|
||
w('- карточка **' + exp.title + '**: ' + line.join(' · '));
|
||
|
||
/* ряд: влезает в одну строку + гипотетическая третья ссылка */
|
||
const row = await page.evaluate('(' + PROBE_ROW_SRC + ')(' + JSON.stringify(sel + ' .case-card__links') + ', ' +
|
||
JSON.stringify({ bukvika: 'Сайт проекта', associations: 'В RuStore', 'first-step-radio': 'Видео' }[exp.slug]) + ', ' +
|
||
JSON.stringify('.case-card__links a svg.btn__icon') + ')');
|
||
if (row) {
|
||
w(' - ряд: контейнер ' + row.containerW + ' px, ряд ' + row.rowW + ' px (' + row.n + ' шт.), в одну строку: ' + (row.oneLine ? '**да**' : 'НЕТ') + ', выход за контейнер ' + row.overflow + ' px');
|
||
if (row.overflow > 0.5) FAILS.push(tag + '/' + exp.slug + ': ряд выходит за контейнер на ' + row.overflow + 'px');
|
||
if (!row.oneLine) FAILS.push(tag + '/' + exp.slug + ': ссылки не влезли в одну строку (' + row.rowW + ' > ' + row.containerW + ')');
|
||
if (row.with3) w(' - ряд из ' + row.with3.n + ' ссылок: ' + row.with3.rowW + ' px, в одну строку: ' + (row.with3.oneLine ? '**да**' : 'нет'), ' выход ' + row.with3.overflow + ' px');
|
||
}
|
||
}
|
||
w();
|
||
|
||
/* полоса оптической массы: разброс по четырём знакам при одном слоте */
|
||
const kinds = Object.keys(cardMass);
|
||
if (kinds.length > 1) {
|
||
const mn = Math.min.apply(null, kinds.map((k) => cardMass[k])), mx = Math.max.apply(null, kinds.map((k) => cardMass[k]));
|
||
w('- оптическая масса знаков в карточке (px², слот 16): ' + kinds.map((k) => k + ' ' + cardMass[k].toFixed(1)).join(' · ') +
|
||
' → разброс max/min = ' + (mx / mn).toFixed(3));
|
||
if (mx / mn > MASS_SPREAD_MAX) FAILS.push(tag + ': разброс оптической массы знаков ' + (mx / mn).toFixed(3) + ' > ' + MASS_SPREAD_MAX);
|
||
w();
|
||
}
|
||
|
||
/* ---------- фокус ---------- */
|
||
await page.keyboard.press('Tab');
|
||
const foc = await page.evaluate(function (sel) {
|
||
const a = document.querySelector(sel);
|
||
if (!a) return null;
|
||
a.focus();
|
||
const cs = getComputedStyle(a);
|
||
return { fv: a.matches(':focus-visible'), w: cs.outlineWidth, s: cs.outlineStyle, c: cs.outlineColor, o: cs.outlineOffset };
|
||
}, '.case-card[data-slug="bukvika"] .case-card__links a');
|
||
w('- :focus-visible на ссылке карточки — ' + (foc && foc.fv ? 'да' : 'НЕТ') + ', кольцо ' + (foc ? foc.w + ' ' + foc.s + ' offset ' + foc.o : '—'));
|
||
if (!foc || !foc.fv || parseFloat(foc.w) < 2 || foc.s === 'none') FAILS.push(tag + ': нет видимого фокус-кольца на ссылке карточки');
|
||
w();
|
||
|
||
await page.locator('.case-card[data-slug="bukvika"]').screenshot({ path: path.join(SHOTS, 'card-' + tag + '.png') });
|
||
await page.locator('.case-card[data-slug="bukvika"] .case-card__links').screenshot({ path: path.join(SHOTS, 'links-' + tag + '.png') });
|
||
|
||
/* ---------- большое окно ---------- */
|
||
await page.evaluate(() => {
|
||
const c = document.querySelector('.case-card[data-slug="first-step-radio"]');
|
||
c.querySelector('.case-card__more').click();
|
||
});
|
||
await page.waitForTimeout(450);
|
||
if (!(await page.evaluate(() => !!document.querySelector('#quickview[open]')))) FAILS.push(tag + ': окно проекта не открылось');
|
||
|
||
const win = await page.evaluate('(' + PROBE_LINKS_SRC + ')("#quickview .quickview__links a")');
|
||
const expW = EXPECT.find((e) => e.slug === 'first-step-radio').links;
|
||
const winMass = {};
|
||
for (let i = 0; i < win.length; i++) {
|
||
const l = win[i], p = tag + '/окно[' + i + ']';
|
||
const exp = expW[i];
|
||
if (!exp) { FAILS.push(p + ': лишняя ссылка «' + l.label + '»'); continue; }
|
||
const [kind, label, href] = exp;
|
||
if (l.label !== label) FAILS.push(p + ': подпись «' + l.label + '» != «' + label + '»');
|
||
if (l.href !== href) FAILS.push(p + ': href ' + l.href + ' != ' + href);
|
||
if (l.viewBox !== '0 0 24 24') FAILS.push(p + ': viewBox ' + l.viewBox + ' != «0 0 24 24»');
|
||
if (!l.groupTf || !/translate\(/.test(l.groupTf)) FAILS.push(p + ': нет группы нормализации');
|
||
if (l.ariaHidden !== 'true' || l.focusable !== 'false') FAILS.push(p + ': aria-hidden/focusable не выставлены');
|
||
if (l.imgInside || l.useExternal) FAILS.push(p + ': знак не инлайновый');
|
||
if (Math.abs(l.iconW - 18) > 0.5 || Math.abs(l.iconH - 18) > 0.5) FAILS.push(p + ': слот знака ' + l.iconW + '×' + l.iconH + ', ожидался квадрат 18×18');
|
||
if (l.w < 24 || l.h < 24) FAILS.push(p + ': hit-area ' + l.w + '×' + l.h + ' < 24×24');
|
||
if (Math.abs(l.h - WIN_BTN_H) > 1) FAILS.push(p + ': высота кнопки ' + l.h + ' px, ожидалось ' + WIN_BTN_H);
|
||
if (l.nowrap !== 'nowrap') FAILS.push(p + ': подпись может рваться (white-space=' + l.nowrap + ')');
|
||
const cr = ratio(l.color, l.bg);
|
||
if (cr < 4.5) FAILS.push(p + ': контраст ' + cr.toFixed(2) + ':1 < 4.5');
|
||
const ink = await page.evaluate('(async function(s, S){ return (' + PROBE_ICON_SRC + ')(s, S); })' +
|
||
'("#quickview .quickview__links a:nth-child(' + (i + 1) + ') svg.btn__icon", 18)');
|
||
const air = ink ? Math.min(ink.margin.left, ink.margin.top, ink.margin.right, ink.margin.bottom) : -1;
|
||
if (!ink) FAILS.push(p + ': знак не растеризован');
|
||
else {
|
||
if (air < INK_MARGIN_MIN) FAILS.push(p + ': чернила упираются в край слота (воздух ' + air + ' px)');
|
||
if (ink.inkh > l.fontSize + 0.01) FAILS.push(p + ': знак выше кегля подписи (' + ink.inkh + ' > ' + l.fontSize + ')');
|
||
if (ink.inkW > l.fontSize * 1.45) FAILS.push(p + ': знак шире кегля подписи (' + ink.inkW + ' > ' + l.fontSize + '×1.45)');
|
||
winMass[kind] = ink.mass;
|
||
}
|
||
w('- окно[' + i + '] «' + l.label + '»' + (i === 0 ? ' [primary]' : ' [ghost]') + ': ' + l.w + '×' + l.h + ' px, слот ' + l.iconW + '×' + l.iconH +
|
||
', чернила ' + (ink ? ink.inkW + '×' + ink.inkh + ' (масса ' + ink.mass.toFixed(1) + ')' : '—') + ', кегль ' + l.fontSize + 'px, ' + cr.toFixed(2) + ':1');
|
||
}
|
||
if (win.length && !/btn--primary/.test(win[0].cls)) FAILS.push(tag + '/окно[0]: первая ссылка не основной CTA (' + win[0].cls + ')');
|
||
if (win.length !== expW.length) FAILS.push(tag + '/окно: ссылок ' + win.length + ', ожидалось ' + expW.length);
|
||
const wk = Object.keys(winMass);
|
||
if (wk.length > 1) {
|
||
const mn = Math.min.apply(null, wk.map((k) => winMass[k])), mx = Math.max.apply(null, wk.map((k) => winMass[k]));
|
||
w('- оптическая масса знаков в окне (px², слот 18): ' + wk.map((k) => k + ' ' + winMass[k].toFixed(1)).join(' · ') + ' → разброс ' + (mx / mn).toFixed(3));
|
||
}
|
||
|
||
const rowW = await page.evaluate('(' + PROBE_ROW_SRC + ')("#quickview .quickview__links", "Видео", "#quickview .quickview__links a svg.btn__icon")');
|
||
if (rowW) {
|
||
w('- ряд окна: контейнер ' + rowW.containerW + ' px, ряд ' + rowW.rowW + ' px (' + rowW.n + ' шт.), в одну строку: ' + (rowW.oneLine ? '**да**' : 'НЕТ') + ', выход ' + rowW.overflow + ' px');
|
||
if (!rowW.oneLine) FAILS.push(tag + '/окно: ссылки не влезли в одну строку (' + rowW.rowW + ' > ' + rowW.containerW + ')');
|
||
if (rowW.overflow > 0.5) FAILS.push(tag + '/окно: ряд выходит за контейнер на ' + rowW.overflow + 'px');
|
||
if (rowW.with3) w('- ряд окна из ' + rowW.with3.n + ' ссылок: ' + rowW.with3.rowW + ' px, в одну строку: ' + (rowW.with3.oneLine ? '**да**' : 'нет') + ', выход ' + rowW.with3.overflow + ' px');
|
||
}
|
||
w();
|
||
|
||
/* фокус в окне */
|
||
const focW = await page.evaluate(function () {
|
||
const a = document.querySelector('#quickview .quickview__links a');
|
||
if (!a) return null;
|
||
a.focus();
|
||
const cs = getComputedStyle(a);
|
||
return { fv: a.matches(':focus-visible'), w: cs.outlineWidth, s: cs.outlineStyle };
|
||
});
|
||
w('- :focus-visible на ссылке окна — ' + (focW && focW.fv ? 'да' : 'НЕТ') + ', кольцо ' + (focW ? focW.w + ' ' + focW.s : '—'));
|
||
if (!focW || !focW.fv || parseFloat(focW.w) < 2 || focW.s === 'none') FAILS.push(tag + ': нет видимого фокус-кольца на ссылке окна');
|
||
w();
|
||
|
||
await page.locator('#quickview .quickview__links').screenshot({ path: path.join(SHOTS, 'winlinks-' + tag + '.png') });
|
||
await page.locator('#quickview .quickview__panel').screenshot({ path: path.join(SHOTS, 'window-' + tag + '.png') });
|
||
|
||
/* состав карточка == окно */
|
||
const cardComp = await page.evaluate(function () {
|
||
const c = document.querySelector('.case-card[data-slug="first-step-radio"]');
|
||
return Array.from(c.querySelectorAll('.case-card__links a')).map((a) => a.textContent.trim() + '|' + a.getAttribute('href'));
|
||
});
|
||
parity.push({ tag, card: cardComp, window: win.map((l) => l.label + '|' + l.href) });
|
||
|
||
await page.evaluate(() => document.querySelector('#qv-close').click());
|
||
await page.waitForTimeout(250);
|
||
|
||
const expected404 = badResp.filter((r) => /Work_files|src\/assets|\.webp|\.png|\.jpg/i.test(r));
|
||
const realBad = badResp.filter((r) => !expected404.includes(r));
|
||
w('- консоль/сеть: JS-ошибок ' + jsErrors.length + ', неожиданных 4xx ' + realBad.length + ', ожидаемых 404 на неприсланные кадры ' + expected404.length);
|
||
jsErrors.forEach((e) => FAILS.push(tag + ': console — ' + e.slice(0, 160)));
|
||
realBad.forEach((e) => FAILS.push(tag + ': сеть — ' + e.slice(0, 160)));
|
||
w();
|
||
await ctx.close();
|
||
}
|
||
}
|
||
await browser.close();
|
||
|
||
w('## 4. Карточка == окно (единственный сборщик — projectLinksHTML)');
|
||
w();
|
||
w('| точка | карточка | окно | совпадает |');
|
||
w('|---|---|---|---|');
|
||
for (const p of parity) {
|
||
const same = JSON.stringify(p.card) === JSON.stringify(p.window);
|
||
w('| ' + p.tag + ' | ' + p.card.join(', ') + ' | ' + p.window.join(', ') + ' | ' + (same ? 'да' : '**НЕТ**') + ' |');
|
||
if (!same) FAILS.push(p.tag + ': состав карточки и окна разошёлся');
|
||
}
|
||
w();
|
||
|
||
w('## Итог');
|
||
w();
|
||
w('- Провалено проверок: ' + FAILS.length);
|
||
FAILS.forEach((f) => w(' - FAIL: ' + f));
|
||
w();
|
||
w('Превью: `' + SHOTS + '` — ' + fs.readdirSync(SHOTS).filter((f) => /\.png$/.test(f)).sort().join(', '));
|
||
fs.writeFileSync(REPORT_MD, L.join('\n') + '\n', 'utf8');
|
||
console.log('\nwritten:', REPORT_MD);
|
||
process.exit(FAILS.length ? 1 : 0);
|
||
})();
|