Files
wekan/tests/uiDensity.test.cjs
T
Lauri Ojansivu b46eecf58b Fix the 20 node suites the && chain had been hiding.
The new runner ran all 260 suites for the first time: 20 failed. Four were real
defects in the app, the rest were guards pinning a spelling or a design that had
since changed - each of them written when it was true, and none of them run
since, because npm stopped the chain at the first failure.

The app fixes:

  * models/lib/themeAccents.js: accentOf('constructor') returned Object's
    constructor - a FUNCTION - because a plain lookup answers from
    Object.prototype. A board colour named after any prototype member would have
    written a function into a stylesheet. Only the map's own keys are themes now.
  * RTL: the dependency overlay and its connect handle each set a physical
    left/right AFTER the logical property, so the physical one won and both were
    pinned to the LTR side in an Arabic or Hebrew layout. The skip link, the
    avatar's account badge, the stats value column and the theme-category label
    were physical too. All logical now (inset-inline-*, text-align: start/end).

The guards, each corrected to what the code actually does now, with the reason:

  * addBoardTileHeight, publicationArgumentGuard: a fixed-size slice
    (jade + 3000, source + 1400) that a grown comment pushed the subject out of.
    Both now take the whole block they are about.
  * adminCheckboxStyle: the Grey Icons feature is gone; asserts its REMOVAL.
  * boardsVisibilitySettings: the separator count was pinned at 3; the site-theme
    picker group made it 4. Asserts the shape - one Save per section, none for
    the picker that applies immediately.
  * changelogFormat: "# Upcoming WeKan ® release" is a legitimate heading.
  * dbConformanceWiring: the log directory honours WEKAN_LOGDIR now.
  * domainTablePage: the default page is the app-wide 10, not 25.
  * ferretdbOplogGating: the exec runs under the CPU launcher.
  * leftMenu: peopleMenu takes the user (multitenancy option D).
  * loginEmailPanesMoved: the board-member restriction is two checkboxes in
    Organizations and Teams now; asserted there.
  * mobileAllBoardsFit: the bell and the avatar are two rules with variants.
  * narrowWindowLayout: the hamburger is the last button in the flow, not pinned.
  * rulesApiTriggerNormalize: #6491 made a missing matching field mean "any
    value", so the #2674 "can never match" case now matches - and removeMember
    iterates assignees, not members.
  * securityLog: the new-problems selector moved to models/lib/eventLogProblems.
  * tablePage: the Cards report renders the page the SERVER named.
  * tenantWiring: the site colour is read in two places; the autorun is the one.
  * themeAccents: see above - the guard was right, the code was not.
  * translationPane: the "no hand-written table" regex matched the +tablePage
    include it also requires.
  * uiDensity: admin table cells wrap in one td+th rule now.
  * rtl: the dir attribute comes from a helper, `!important` is not part of a
    value, and the scanner read CSS COMMENTS as declarations - the comment
    explaining why `left: 50%` needs no RTL variant was reported as a violation.

Thanks to xet7 !
2026-07-28 04:28:36 +03:00

200 lines
10 KiB
JavaScript

'use strict';
// Plain-Node UI regression guard (no Meteor, no browser) for issue #6465:
// desktop density regressions from the v7.98-v8.18 mobile UI work, restored to
// the WeKan 6.09 look. Follows the repo's CSS-guard test style (see
// tests/minicardLabelHeight.test.cjs).
// Run: node tests/uiDensity.test.cjs
//
// Guards, with the regression each one blocks:
// - base font 14px/18px (v7.98 clamp -> 18px on desktop, "+28.5% on everything")
// - headings 22/18/16px (vw clamps -> 24/20/18px on desktop)
// - All Boards wrapper 10px/15px (2vh/2vw -> huge empty header band)
// - card details docks RIGHT (v8.18 floating window opened ON TOP of its own card)
// - card canvas padding 20px (2.5vw -> ~48px white borders on FullHD)
// - no force-all-card-text rule (everything in card details rendered title-sized)
// - admin table headers wrap (nowrap + "Select all / Unselect all" text -> huge columns)
// - zoom pill fixed-px (vh/vw pill taller than its 28px overflow-hidden row = cut off)
// - one-click board settings cog (board menu needed two clicks)
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const repoRoot = path.resolve(__dirname, '..');
const read = rel => fs.readFileSync(path.join(repoRoot, rel), 'utf8');
const squish = s => s.replace(/\s+/g, ' ');
const layouts = read('client/components/main/layouts.css');
const cardDetails = read('client/components/cards/cardDetails.css');
const header = read('client/components/main/header.css');
const settingBody = read('client/components/settings/settingBody.css');
const peopleBody = read('client/components/settings/peopleBody.jade');
const boardHeader = read('client/components/boards/boardHeader.jade');
const listHeader = read('client/components/lists/listHeader.jade');
let passed = 0;
function test(name, fn) {
fn();
passed += 1;
console.log(' ok -', name);
}
// --- Global density -----------------------------------------------------------
test('base font is the 6.09 fixed 14px/18px', () => {
const base = layouts.match(/html,\s*\nbody,\s*\ninput,[\s\S]*?\{[\s\S]*?\}/);
assert.ok(base, 'base font rule found');
assert.ok(base[0].includes('font: 14px Roboto'));
assert.ok(base[0].includes('line-height: 18px'));
// negative: the desktop-inflating clamp must not come back
assert.ok(!/font:\s*clamp\(/.test(base[0]));
});
test('headings are the 6.09 sizes 22/18/16px', () => {
assert.ok(/h1 \{\s*\n\s*font-size: 22px;/.test(layouts));
assert.ok(/h2 \{\s*\n\s*font-size: 18px;/.test(layouts));
assert.ok(/h3,\s*\nh4,\s*\nh5,\s*\nh6 \{\s*\n\s*font-size: 16px;/.test(layouts));
});
test('All Boards wrapper is back to compact 10px/15px', () => {
const wrapper = layouts.match(/#content > \.wrapper \{[\s\S]*?\}/);
assert.ok(wrapper, 'wrapper rule found');
assert.ok(wrapper[0].includes('margin-top: 10px'));
assert.ok(wrapper[0].includes('padding: 15px'));
// strip comments — the explanatory comment cites the old vh/vw values
const declarationsOnly = wrapper[0].replace(/\/\*[\s\S]*?\*\//g, '');
assert.ok(!/[0-9]v[hw]/.test(squish(declarationsOnly)), 'no viewport-relative padding');
});
// --- Card details window --------------------------------------------------------
test('card details default position docks to the END edge, not over the card', () => {
const rule = cardDetails.match(
/body\.desktop-mode \.card-details:not\(\.card-details-popup\):not\(\[style\*="left"\]\):not\(\[style\*="top"\]\) \{[\s\S]*?\}/,
);
assert.ok(rule, 'default-position rule found');
assert.ok(rule[0].includes('inset-inline-start: auto'));
assert.ok(rule[0].includes('inset-inline-end: 8px'));
assert.ok(rule[0].includes('width: min(650px, 90vw)'));
// negative: the v8.18 whole-board overlay anchored at the start edge
assert.ok(!rule[0].includes('inset-inline-start: 20px'));
});
test('card details canvas padding is the 6.09 fixed 20px', () => {
assert.ok(/\.card-details \.card-details-canvas \{[\s\S]*?padding: 0 20px;/.test(cardDetails));
assert.ok(!cardDetails.includes('padding: 0 2.5vw'), 'no ~48px viewport borders');
});
test('the force-all-card-text-to-title-size block is gone', () => {
assert.ok(!cardDetails.includes('.card-details select,'),
'the v8.18 selector list that flattened the text hierarchy must stay removed');
assert.ok(!cardDetails.includes('.card-details p,'));
});
test('desktop card window uses a small 3px radius', () => {
const fixed = cardDetails.match(
/body\.desktop-mode \.card-details:not\(\.card-details-popup\) \{[\s\S]*?\}/,
);
assert.ok(fixed, 'desktop-mode rule found');
assert.ok(fixed[0].includes('border-radius: 3px'));
assert.ok(!fixed[0].includes('border-radius: 8px'));
});
// --- Admin panel tables ---------------------------------------------------------
test('org/team feature column headers use compact icon links', () => {
// The org headers are one shared template now, parameterised by feature and
// rendered through the table page's headerTemplate slot
// (docs/Design/Page/Table.md) - three copies of the same select-all pair became
// one. Same compact icon links, one definition.
assert.ok(/a\.js-org-feature-all\(href="#", data-feature="\{\{feature\}\}", data-value="true", title="\{\{_ 'select-all'\}\}"\)\s*\n\s*i\.fa\.fa-check-square-o/.test(peopleBody));
const js = fs.readFileSync(path.join(__dirname, '..', 'client/components/settings/peopleBody.js'), 'utf8');
for (const feature of ['orgSharedTemplates', 'orgPropagateMembersToBoards', 'orgSyncMembersFromAuth']) {
assert.ok(js.includes(`feature: '${feature}'`), `${feature} must still have a header`);
}
// Teams the same way: one parameterised header template, not three copies.
assert.ok(/a\.js-team-feature-all\(href="#", data-feature="\{\{feature\}\}", data-value="false", title="\{\{_ 'unselect-all'\}\}"\)\s*\n\s*i\.fa\.fa-square-o/.test(peopleBody));
for (const feature of ['teamSharedTemplates', 'teamPropagateMembersToBoards', 'teamSyncMembersFromAuth']) {
assert.ok(js.includes(`feature: '${feature}'`), `${feature} must still have a header`);
}
// negative: no full-text links blowing the column width up
assert.ok(!/data-value="true"\) \{\{_ 'select-all'\}\}/.test(peopleBody));
assert.ok(!/data-value="false"\) \{\{_ 'unselect-all'\}\}/.test(peopleBody));
});
test('admin table cells wrap instead of pushing the table off screen', () => {
// These apply to the WIDE admin tables only - GridFS stats, Version, Translation.
// The shared table page is excluded: it is width:100% with wrapping cells so that
// it fits, and nowrap + a per-column minimum pushed its right edge off screen.
//
// BOTH cells wrap now, in one rule: `td` kept `nowrap` for horizontal scrolling
// until a version string, a path or an id widened its column and pushed the
// table off screen anyway - the very thing the scrolling was for.
const cells = settingBody.match(
/\.main-body table:not\(\.table-page-table\) td,\s*\n[^{]*th \{([^}]*)\}/);
assert.ok(cells, 'the shared td+th rule must be there');
assert.ok(/white-space: normal/.test(cells[1]), 'long values wrap');
assert.ok(/overflow-wrap: anywhere/.test(cells[1]),
'and an unbroken string breaks inside its cell rather than widening the column');
assert.ok(!/white-space:\s*nowrap/.test(cells[1]), 'nothing here is nowrap any more');
// The header still has its own width cap (#6465). There are several rules whose
// selector ends in `th {` - including the shared one above - so find the one
// that sets the cap rather than assuming it is the first.
const thRules = [...settingBody.matchAll(
/\.main-body table:not\(\.table-page-table\) th \{([^}]*)\}/g)].map(m => m[1]);
assert.ok(thRules.some(body => /max-width: 240px/.test(body)),
'a long header label cannot widen a column');
});
// --- Zoom pill -------------------------------------------------------------------
test('zoom pill fits inside the 28px quick-access row', () => {
const pill = header.match(/#header-quick-access \.zoom-controls \{[\s\S]*?\}/);
assert.ok(pill, 'zoom-controls rule found');
assert.ok(pill[0].includes('padding: 2px 8px'));
assert.ok(pill[0].includes('max-height: 24px'));
// negative: no viewport-relative sizing that outgrew the clipped row
assert.ok(!pill[0].includes('0.5vh 1vw'));
});
// --- Right-docked card window must not trap the sidebar ---------------------------
test('archiving/deleting a card closes its details window (openCards cleanup)', () => {
// #6465 follow-up: the right-docked window (z-index 2001) otherwise stays
// rendered over the archives sidebar, intercepting its Restore/Delete links.
const cardDetailsJs = read('client/components/cards/cardDetails.js');
const archive = cardDetailsJs.match(/'click \.js-archive':[\s\S]*?\n \}\),/);
assert.ok(archive, 'archive handler found');
assert.ok(/Session\.set\('openCards',[\s\S]*?filter\(\(id\) => id !== card\._id\)/.test(archive[0]),
'archive must drop the card from openCards');
const del = cardDetailsJs.match(/'click \.js-delete': Popup\.afterConfirm\('cardDelete'[\s\S]*?\n \}\),/);
assert.ok(del, 'delete handler found');
assert.ok(/Session\.set\('openCards',[\s\S]*?filter\(\(id\) => id !== card\._id\)/.test(del[0]),
'delete must drop the card from openCards');
});
test('an OPEN sidebar stacks above the right-docked card window', () => {
const sidebar = read('client/components/sidebar/sidebar.css');
const open = sidebar.match(/\.board-sidebar\.is-open \{[\s\S]*?\}/);
assert.ok(open, 'is-open rule found');
assert.ok(open[0].includes('z-index: 2002'),
'sidebar must beat the card window\'s z-index 2001 when the user opens it');
});
// --- One-click board settings + list link -----------------------------------------
test('board header has a one-click board settings cog', () => {
// The board-menu cog lives in the sidebar header (client/components/sidebar/sidebar.jade),
// not boardHeader.jade.
const sidebar = read('client/components/sidebar/sidebar.jade');
assert.ok(/a\.board-header-btn\.js-open-board-menu\(title="\{\{_ 'boardMenuPopup-title'\}\}"\)\s*\n\s*i\.fa\.fa-cog/.test(sidebar));
});
test('list More popup link input uses a real helper (#6459 companion)', () => {
assert.ok(listHeader.includes('value="{{ absoluteUrl }}"'));
assert.ok(!/value="\{\{ rootUrl \}\}"/.test(listHeader), 'rootUrl helper does not exist');
});
console.log(`\n${passed} tests passed`);