import assert from 'node:assert/strict'; import test from 'node:test'; import { readFile } from 'node:fs/promises'; import { calculateVisualContextMenuPosition } from '../admin/js/views/schedule.js'; test('меню пары открывается справа от кнопки с тремя точками', () => { assert.deepEqual(calculateVisualContextMenuPosition({ anchorRect: { left: 100, right: 120, top: 80, bottom: 100 }, menuWidth: 220, menuHeight: 120, viewportWidth: 1280, viewportHeight: 720 }), { left: 128, top: 80 }); }); test('у края экрана меню раскрывается влево и остаётся в viewport', () => { assert.deepEqual(calculateVisualContextMenuPosition({ anchorRect: { left: 1240, right: 1260, top: 680, bottom: 700 }, menuWidth: 220, menuHeight: 160, viewportWidth: 1280, viewportHeight: 720 }), { left: 1012, top: 540 }); }); test('контекстное меню больше не центрируется стилями', async () => { const styles = await readFile(new URL('../admin/css/components.css', import.meta.url), 'utf8'); const menuRule = styles.match(/\.schedule-visual-context-menu\s*\{([\s\S]*?)\}/)?.[1] || ''; assert.doesNotMatch(menuRule, /translate\(-50%,\s*-50%\)/); assert.match(menuRule, /position:\s*fixed/); });