mirror of
https://github.com/ancsemi/Haven.git
synced 2026-10-27 09:05:01 +00:00
style.css now only imports the parts in order, after voice.css and music.css as before, so the cascade is unchanged. Each cut sits between top-level rules. Checked twice: the parts (minus the one-line header each got) rebuild the old file byte for byte, and a browser loading the new style.css ends up with the same 3,526 rules, in the same order, as it parses from the old one. The largest part is 1,559 lines. Tests that read style.css now read it with its imports filled in (test/coreCss.js), and the theme contract test names the part each checked rule lives in.
68 lines
2.6 KiB
JavaScript
68 lines
2.6 KiB
JavaScript
'use strict';
|
|
|
|
/**
|
|
* Forum list / gallery / feed chrome and gallery tile sliders.
|
|
*
|
|
* node --test test/forumViews.test.js
|
|
*/
|
|
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const test = require('node:test');
|
|
|
|
const ROOT = path.join(__dirname, '..');
|
|
const forum = fs.readFileSync(path.join(ROOT, 'public/js/modules/app-forum.js'), 'utf8');
|
|
const gallery = fs.readFileSync(path.join(ROOT, 'public/js/modules/app-media-gallery.js'), 'utf8');
|
|
const css = require('./coreCss').readCoreCss();
|
|
const html = fs.readFileSync(path.join(ROOT, 'public/app.html'), 'utf8');
|
|
|
|
function parseView(v) { return v === 'gallery' || v === 'feed' ? v : 'list'; }
|
|
function parseTile(v) {
|
|
const n = Number(v);
|
|
if (!Number.isFinite(n)) return 11;
|
|
return Math.min(28, Math.max(7, Math.round(n * 2) / 2));
|
|
}
|
|
function mediaTilePx(raw) {
|
|
const n = parseInt(raw, 10);
|
|
if (!Number.isFinite(n)) return 150;
|
|
return Math.min(360, Math.max(72, n));
|
|
}
|
|
|
|
test('forum prefs keep list, gallery, and feed, and clamp tile size', () => {
|
|
assert.equal(parseView('feed'), 'feed');
|
|
assert.equal(parseView('gallery'), 'gallery');
|
|
assert.equal(parseView('list'), 'list');
|
|
assert.equal(parseView('cards'), 'list');
|
|
assert.equal(parseTile(undefined), 11);
|
|
assert.equal(parseTile(3), 7);
|
|
assert.equal(parseTile(40), 28);
|
|
assert.equal(parseTile(11.2), 11);
|
|
assert.equal(parseTile(11.8), 12);
|
|
assert.match(forum, /_forumParseView\(v\) \{ return v === 'gallery' \|\| v === 'feed' \? v : 'list'; \}/);
|
|
assert.match(forum, /Math\.min\(28, Math\.max\(7,/);
|
|
assert.match(forum, /data-view="feed"/);
|
|
assert.match(forum, /id="forum-tile-size"/);
|
|
assert.match(forum, /_forumAvatarHtml/);
|
|
});
|
|
|
|
test('forum gallery tiles follow --forum-tile and feed is a single column', () => {
|
|
assert.match(css, /minmax\(var\(--forum-tile, 11rem\), 1fr\)/);
|
|
assert.match(css, /\.messages\.forum-feed \.forum-topics/);
|
|
assert.match(css, /\.messages\.forum-feed \.forum-topic-avatar/);
|
|
assert.match(css, /\.messages\.forum-feed \.forum-topic-thumb-empty \{ display: none; \}/);
|
|
assert.match(forum, /classList\.toggle\('forum-feed', p\.view === 'feed'\)/);
|
|
});
|
|
|
|
test('files and media photos have a tile size slider', () => {
|
|
assert.equal(mediaTilePx('72'), 72);
|
|
assert.equal(mediaTilePx('360'), 360);
|
|
assert.equal(mediaTilePx('10'), 72);
|
|
assert.equal(mediaTilePx('999'), 360);
|
|
assert.equal(mediaTilePx('nope'), 150);
|
|
assert.match(html, /id="media-gallery-tile"/);
|
|
assert.match(gallery, /_mediaTilePx/);
|
|
assert.match(gallery, /_applyMediaTileSize/);
|
|
assert.match(css, /minmax\(var\(--media-tile, 150px\), 1fr\)/);
|
|
});
|