Files
Haven/test/channelDragAutoscroll.test.js
T
ancsemi da8148fccc Split app-channels.js (3,400 lines) into four files by area, a pure move
Switching channels, the topic bar, drawing the sidebar and keyboard navigation
stay in app-channels.js (1,294 lines). The "..." menus, hidden channels and the
Channel Functions panel moved to app-channel-context.js; the sub-channel panel,
moving channels and the Organize windows to app-channel-organize.js; unread
badges, notifications and drag-and-drop to app-channel-unread.js.

Checked: all 1,131 methods have identical source after merging. The context
menu, Channel Functions, hiding and unhiding, sub-channels, Organize, unread
badges and the quick switcher were exercised live.
2026-10-02 11:26:15 -04:00

30 lines
1.5 KiB
JavaScript

'use strict';
// Chromium's native drag-and-drop never auto-scrolls a nested overflow
// container, so a channel dragged to the edge of a long sidebar stopped
// there. _makeEdgeScroller drives the scroll from dragover. Its DOM behaviour
// was checked in a real Chromium (scrolls at both edges, idles in the middle,
// stops on demand); this test locks the wiring.
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const test = require('node:test');
const src = fs.readFileSync(path.join(__dirname, '..', 'public', 'js', 'modules', 'app-channel-unread.js'), 'utf8');
test('the edge scroller exists and walks up to the element that really scrolls', () => {
assert.match(src, /_makeEdgeScroller\(listEl, edge = 48, maxSpeed = 18\)/);
assert.match(src, /getComputedStyle\(el\)\.overflowY/);
});
test('channel and DM drag handlers feed it on dragover and stop it on drop and cleanup', () => {
const channel = src.slice(src.indexOf('_setupChannelDragDrop() {'), src.indexOf('_setupDmDragDrop() {'));
const dm = src.slice(src.indexOf('_setupDmDragDrop() {'));
for (const [name, block] of [['channel', channel], ['dm', dm]]) {
assert.match(block, /const edge = this\._makeEdgeScroller\(/, `${name}: scroller created`);
assert.match(block, /edge\.onDragOver\(e\.clientY\)/, `${name}: dragover drives it`);
assert.ok((block.match(/edge\.stop\(\)/g) || []).length >= 2, `${name}: stopped on drop and in cleanup`);
}
});